Skip to content

Commit

Permalink
🚀 Rename to Rumale
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshoku committed Mar 1, 2019
1 parent e81c102 commit 8671613
Show file tree
Hide file tree
Showing 146 changed files with 594 additions and 611 deletions.
1 change: 1 addition & 0 deletions .rspec
@@ -1,2 +1,3 @@
--format documentation
--color
--require spec_helper
2 changes: 1 addition & 1 deletion .rubocop.yml
@@ -1,7 +1,7 @@
inherit_from: .rubocop_todo.yml

AllCops:
TargetRubyVersion: 2.2
TargetRubyVersion: 2.3
DisplayCopNames: true
DisplayStyleGuide: true

Expand Down
6 changes: 3 additions & 3 deletions .rubocop_todo.yml
Expand Up @@ -10,21 +10,21 @@
# Cop supports --auto-correct.
Layout/ClosingHeredocIndentation:
Exclude:
- 'svmkit.gemspec'
- 'rumale.gemspec'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent
Layout/IndentHeredoc:
Exclude:
- 'svmkit.gemspec'
- 'rumale.gemspec'

# Offense count: 1
# Cop supports --auto-correct.
Layout/LeadingBlankLines:
Exclude:
- 'svmkit.gemspec'
- 'rumale.gemspec'

# Offense count: 1
# Configuration parameters: CountComments, ExcludedMethods.
Expand Down
2 changes: 0 additions & 2 deletions .travis.yml
Expand Up @@ -3,8 +3,6 @@ os: linux
dist: trusty
language: ruby
rvm:
- 2.1
- 2.2
- 2.3
- 2.4
- 2.5
Expand Down
5 changes: 1 addition & 4 deletions CHANGELOG.md
@@ -1,9 +1,6 @@
# 0.8.0
## Information
- Rename the project to [Rumale](https://github.com/yoshoku/Rumale).
- SVMKit has been deprecated and has been renamed to Rumale. SVMKit will release only bugfix.

## Breaking changes
- Rename SVMKit to Rumale.
- Rename SGDLienareEstimator class to BaseLienarModel class.
- Add data type option to load_libsvm_file method. By default, the method represents the feature with Numo::DFloat.

Expand Down
4 changes: 1 addition & 3 deletions Gemfile
@@ -1,6 +1,4 @@
source 'https://rubygems.org'

git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }

# Specify your gem's dependencies in svmkit.gemspec
# Specify your gem's dependencies in rumale.gemspec
gemspec
82 changes: 40 additions & 42 deletions README.md
@@ -1,29 +1,27 @@
# SVMKit

[![Build Status](https://travis-ci.org/yoshoku/svmkit.svg?branch=master)](https://travis-ci.org/yoshoku/svmkit)
[![Coverage Status](https://coveralls.io/repos/github/yoshoku/svmkit/badge.svg?branch=master)](https://coveralls.io/github/yoshoku/svmkit?branch=master)
[![Gem Version](https://badge.fury.io/rb/svmkit.svg)](https://badge.fury.io/rb/svmkit)
[![BSD 2-Clause License](https://img.shields.io/badge/License-BSD%202--Clause-orange.svg)](https://github.com/yoshoku/svmkit/blob/master/LICENSE.txt)
[![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](https://www.rubydoc.info/gems/svmkit/)

SVMKit has been deprecated and has been renamed to [Rumale](https://github.com/yoshoku/rumale).
Initially, I started developing SVMKit as an experimental library aiming at implementing SVM in Ruby.
However, since I added many other machine learning algorithms to SVMKit, I decided to change the library name.
SVMKit will continue releasing for bugfix but will not add new features.

SVMKit is a machine learninig library in Ruby.
SVMKit provides machine learning algorithms with interfaces similar to Scikit-Learn in Python.
SVMKit supports Linear / Kernel Support Vector Machine,
# Rumale

[![Build Status](https://travis-ci.org/yoshoku/rumale.svg?branch=master)](https://travis-ci.org/yoshoku/rumale)
[![Coverage Status](https://coveralls.io/repos/github/yoshoku/rumale/badge.svg?branch=master)](https://coveralls.io/github/yoshoku/rumale?branch=master)
[![Gem Version](https://badge.fury.io/rb/rumale.svg)](https://badge.fury.io/rb/rumale)
[![BSD 2-Clause License](https://img.shields.io/badge/License-BSD%202--Clause-orange.svg)](https://github.com/yoshoku/rumale/blob/master/LICENSE.txt)
[![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](https://www.rubydoc.info/gems/rumale/)

Rumale (**Ru**by **ma**chine **le**arning) is a machine learninig library in Ruby.
Rumale provides machine learning algorithms with interfaces similar to Scikit-Learn in Python.
Rumale supports Linear / Kernel Support Vector Machine,
Logistic Regression, Linear Regression, Ridge, Lasso, Factorization Machine,
Naive Bayes, Decision Tree, AdaBoost, Random Forest, K-nearest neighbor classifier,
K-Means, DBSCAN, Principal Component Analysis, and Non-negative Matrix Factorization.

This project was formerly known as SVMKit.
If you use SVMKit, please replace `SVMKit` constants with `Rumale`.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'svmkit'
gem 'rumale'
```

And then execute:
Expand All @@ -32,13 +30,13 @@ And then execute:

Or install it yourself as:

$ gem install svmkit
$ gem install rumale

## Usage

### Example 1. Pendigits dataset classification

SVMKit provides function loading libsvm format dataset file.
Rumale provides function loading libsvm format dataset file.
We start by downloading the pendigits dataset from LIBSVM Data web site.

```bash
Expand All @@ -49,17 +47,17 @@ $ wget https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/multiclass/pendig
Training of the classifier with Linear SVM and RBF kernel feature map is the following code.

```ruby
require 'svmkit'
require 'rumale'

# Load the training dataset.
samples, labels = SVMKit::Dataset.load_libsvm_file('pendigits')
samples, labels = Rumale::Dataset.load_libsvm_file('pendigits')

# Map training data to RBF kernel feature space.
transformer = SVMKit::KernelApproximation::RBF.new(gamma: 0.0001, n_components: 1024, random_seed: 1)
transformer = Rumale::KernelApproximation::RBF.new(gamma: 0.0001, n_components: 1024, random_seed: 1)
transformed = transformer.fit_transform(samples)

# Train linear SVM classifier.
classifier = SVMKit::LinearModel::SVC.new(reg_param: 0.0001, max_iter: 1000, batch_size: 50, random_seed: 1)
classifier = Rumale::LinearModel::SVC.new(reg_param: 0.0001, max_iter: 1000, batch_size: 50, random_seed: 1)
classifier.fit(transformed, labels)

# Save the model.
Expand All @@ -70,10 +68,10 @@ File.open('classifier.dat', 'wb') { |f| f.write(Marshal.dump(classifier)) }
Classifying testing data with the trained classifier is the following code.

```ruby
require 'svmkit'
require 'rumale'

# Load the testing dataset.
samples, labels = SVMKit::Dataset.load_libsvm_file('pendigits.t')
samples, labels = Rumale::Dataset.load_libsvm_file('pendigits.t')

# Load the model.
transformer = Marshal.load(File.binread('transformer.dat'))
Expand All @@ -87,7 +85,7 @@ puts("Accuracy: %.1f%%" % (100.0 * classifier.score(transformed, labels)))

# Other evaluating approach
# results = classifier.predict(transformed)
# evaluator = SVMKit::EvaluationMeasure::Accuracy.new
# evaluator = Rumale::EvaluationMeasure::Accuracy.new
# puts("Accuracy: %.1f%%" % (100.0 * evaluator.score(results, labels)))
```

Expand All @@ -102,18 +100,18 @@ Accuracy: 98.4%
### Example 2. Cross-validation

```ruby
require 'svmkit'
require 'rumale'

# Load dataset.
samples, labels = SVMKit::Dataset.load_libsvm_file('pendigits')
samples, labels = Rumale::Dataset.load_libsvm_file('pendigits')

# Define the estimator to be evaluated.
lr = SVMKit::LinearModel::LogisticRegression.new(reg_param: 0.0001, random_seed: 1)
lr = Rumale::LinearModel::LogisticRegression.new(reg_param: 0.0001, random_seed: 1)

# Define the evaluation measure, splitting strategy, and cross validation.
ev = SVMKit::EvaluationMeasure::LogLoss.new
kf = SVMKit::ModelSelection::StratifiedKFold.new(n_splits: 5, shuffle: true, random_seed: 1)
cv = SVMKit::ModelSelection::CrossValidation.new(estimator: lr, splitter: kf, evaluator: ev)
ev = Rumale::EvaluationMeasure::LogLoss.new
kf = Rumale::ModelSelection::StratifiedKFold.new(n_splits: 5, shuffle: true, random_seed: 1)
cv = Rumale::ModelSelection::CrossValidation.new(estimator: lr, splitter: kf, evaluator: ev)

# Perform 5-cross validation.
report = cv.perform(samples, labels)
Expand All @@ -126,19 +124,19 @@ puts("5-CV mean log-loss: %.3f" % mean_logloss)
### Example 3. Pipeline

```ruby
require 'svmkit'
require 'rumale'

# Load dataset.
samples, labels = SVMKit::Dataset.load_libsvm_file('pendigits')
samples, labels = Rumale::Dataset.load_libsvm_file('pendigits')

# Construct pipeline with kernel approximation and SVC.
rbf = SVMKit::KernelApproximation::RBF.new(gamma: 0.0001, n_components: 800, random_seed: 1)
svc = SVMKit::LinearModel::SVC.new(reg_param: 0.0001, max_iter: 1000, random_seed: 1)
pipeline = SVMKit::Pipeline::Pipeline.new(steps: { trns: rbf, clsf: svc })
rbf = Rumale::KernelApproximation::RBF.new(gamma: 0.0001, n_components: 800, random_seed: 1)
svc = Rumale::LinearModel::SVC.new(reg_param: 0.0001, max_iter: 1000, random_seed: 1)
pipeline = Rumale::Pipeline::Pipeline.new(steps: { trns: rbf, clsf: svc })

# Define the splitting strategy and cross validation.
kf = SVMKit::ModelSelection::StratifiedKFold.new(n_splits: 5, shuffle: true, random_seed: 1)
cv = SVMKit::ModelSelection::CrossValidation.new(estimator: pipeline, splitter: kf)
kf = Rumale::ModelSelection::StratifiedKFold.new(n_splits: 5, shuffle: true, random_seed: 1)
cv = Rumale::ModelSelection::CrossValidation.new(estimator: pipeline, splitter: kf)

# Perform 5-cross validation.
report = cv.perform(samples, labels)
Expand All @@ -163,7 +161,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/yoshoku/svmkit.
Bug reports and pull requests are welcome on GitHub at https://github.com/yoshoku/Rumale.
This project is intended to be a safe, welcoming space for collaboration,
and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.

Expand All @@ -173,5 +171,5 @@ The gem is available as open source under the terms of the [BSD 2-clause License

## Code of Conduct

Everyone interacting in the SVMKit project’s codebases, issue trackers,
chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/yoshoku/svmkit/blob/master/CODE_OF_CONDUCT.md).
Everyone interacting in the Rumale project’s codebases, issue trackers,
chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/yoshoku/Rumale/blob/master/CODE_OF_CONDUCT.md).
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -3,4 +3,4 @@ require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:spec)

task default: :spec
task :default => :spec
8 changes: 4 additions & 4 deletions bin/console
@@ -1,14 +1,14 @@
#!/usr/bin/env ruby

require "bundler/setup"
require "svmkit"
require 'bundler/setup'
require 'rumale'

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.

# (If you use this, don't forget to add pry to your Gemfile!)
# require "pry"
# require 'pry'
# Pry.start

require "irb"
require 'irb'
IRB.start(__FILE__)
70 changes: 70 additions & 0 deletions lib/rumale.rb
@@ -0,0 +1,70 @@
# frozen_string_literal: true

require 'numo/narray'

require 'rumale/version'
require 'rumale/validation'
require 'rumale/values'
require 'rumale/utils'
require 'rumale/pairwise_metric'
require 'rumale/dataset'
require 'rumale/probabilistic_output'
require 'rumale/base/base_estimator'
require 'rumale/base/classifier'
require 'rumale/base/regressor'
require 'rumale/base/cluster_analyzer'
require 'rumale/base/transformer'
require 'rumale/base/splitter'
require 'rumale/base/evaluator'
require 'rumale/optimizer/sgd'
require 'rumale/optimizer/rmsprop'
require 'rumale/optimizer/nadam'
require 'rumale/optimizer/yellow_fin'
require 'rumale/pipeline/pipeline'
require 'rumale/kernel_approximation/rbf'
require 'rumale/linear_model/base_linear_model'
require 'rumale/linear_model/svc'
require 'rumale/linear_model/svr'
require 'rumale/linear_model/logistic_regression'
require 'rumale/linear_model/linear_regression'
require 'rumale/linear_model/ridge'
require 'rumale/linear_model/lasso'
require 'rumale/kernel_machine/kernel_svc'
require 'rumale/polynomial_model/base_factorization_machine'
require 'rumale/polynomial_model/factorization_machine_classifier'
require 'rumale/polynomial_model/factorization_machine_regressor'
require 'rumale/multiclass/one_vs_rest_classifier'
require 'rumale/nearest_neighbors/k_neighbors_classifier'
require 'rumale/nearest_neighbors/k_neighbors_regressor'
require 'rumale/naive_bayes/naive_bayes'
require 'rumale/tree/node'
require 'rumale/tree/base_decision_tree'
require 'rumale/tree/decision_tree_classifier'
require 'rumale/tree/decision_tree_regressor'
require 'rumale/ensemble/ada_boost_classifier'
require 'rumale/ensemble/ada_boost_regressor'
require 'rumale/ensemble/random_forest_classifier'
require 'rumale/ensemble/random_forest_regressor'
require 'rumale/clustering/k_means'
require 'rumale/clustering/dbscan'
require 'rumale/decomposition/pca'
require 'rumale/decomposition/nmf'
require 'rumale/preprocessing/l2_normalizer'
require 'rumale/preprocessing/min_max_scaler'
require 'rumale/preprocessing/standard_scaler'
require 'rumale/preprocessing/label_encoder'
require 'rumale/preprocessing/one_hot_encoder'
require 'rumale/model_selection/k_fold'
require 'rumale/model_selection/stratified_k_fold'
require 'rumale/model_selection/cross_validation'
require 'rumale/model_selection/grid_search_cv'
require 'rumale/evaluation_measure/accuracy'
require 'rumale/evaluation_measure/precision'
require 'rumale/evaluation_measure/recall'
require 'rumale/evaluation_measure/f_score'
require 'rumale/evaluation_measure/log_loss'
require 'rumale/evaluation_measure/r2_score'
require 'rumale/evaluation_measure/mean_squared_error'
require 'rumale/evaluation_measure/mean_absolute_error'
require 'rumale/evaluation_measure/purity'
require 'rumale/evaluation_measure/normalized_mutual_information'
@@ -1,9 +1,9 @@
# frozen_string_literal: true

module SVMKit
module Rumale
# This module consists of basic mix-in classes.
module Base
# Base module for all estimators in SVMKit.
# Base module for all estimators in Rumale.
module BaseEstimator
# Return parameters about an estimator.
# @return [Hash]
Expand Down
10 changes: 5 additions & 5 deletions lib/svmkit/base/classifier.rb → lib/rumale/base/classifier.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true

require 'svmkit/validation'
require 'svmkit/evaluation_measure/accuracy'
require 'rumale/validation'
require 'rumale/evaluation_measure/accuracy'

module SVMKit
module Rumale
module Base
# Module for all classifiers in SVMKit.
# Module for all classifiers in Rumale.
module Classifier
include Validation

Expand All @@ -28,7 +28,7 @@ def score(x, y)
check_sample_array(x)
check_label_array(y)
check_sample_label_size(x, y)
evaluator = SVMKit::EvaluationMeasure::Accuracy.new
evaluator = Rumale::EvaluationMeasure::Accuracy.new
evaluator.score(y, predict(x))
end
end
Expand Down
@@ -1,11 +1,11 @@
# frozen_string_literal: true

require 'svmkit/validation'
require 'svmkit/evaluation_measure/purity'
require 'rumale/validation'
require 'rumale/evaluation_measure/purity'

module SVMKit
module Rumale
module Base
# Module for all clustering algorithms in SVMKit.
# Module for all clustering algorithms in Rumale.
module ClusterAnalyzer
include Validation

Expand All @@ -23,7 +23,7 @@ def score(x, y)
check_sample_array(x)
check_label_array(y)
check_sample_label_size(x, y)
evaluator = SVMKit::EvaluationMeasure::Purity.new
evaluator = Rumale::EvaluationMeasure::Purity.new
evaluator.score(y, fit_predict(x))
end
end
Expand Down

0 comments on commit 8671613

Please sign in to comment.