All Projects → yoshoku → Rumale

yoshoku / Rumale

Licence: bsd-2-clause
Rumale is a machine learning library in Ruby

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Rumale

Pycm
Multi-class confusion matrix library in Python
Stars: ✭ 1,076 (+104.56%)
Mutual labels:  artificial-intelligence, data-science, data-analysis, ml
Nlpaug
Data augmentation for NLP
Stars: ✭ 2,761 (+424.9%)
Mutual labels:  artificial-intelligence, data-science, ml
Modelchimp
Experiment tracking for machine and deep learning projects
Stars: ✭ 121 (-77%)
Mutual labels:  artificial-intelligence, data-science, ml
Datascience
Curated list of Python resources for data science.
Stars: ✭ 3,051 (+480.04%)
Mutual labels:  artificial-intelligence, data-science, data-analysis
Pandas Profiling
Create HTML profiling reports from pandas DataFrame objects
Stars: ✭ 8,329 (+1483.46%)
Mutual labels:  artificial-intelligence, data-science, data-analysis
Ai Expert Roadmap
Roadmap to becoming an Artificial Intelligence Expert in 2021
Stars: ✭ 15,441 (+2835.55%)
Mutual labels:  artificial-intelligence, data-science, data-analysis
Imodels
Interpretable ML package 🔍 for concise, transparent, and accurate predictive modeling (sklearn-compatible).
Stars: ✭ 194 (-63.12%)
Mutual labels:  artificial-intelligence, data-science, ml
Fklearn
fklearn: Functional Machine Learning
Stars: ✭ 1,305 (+148.1%)
Mutual labels:  data-science, data-analysis, ml
Atlas
An Open Source, Self-Hosted Platform For Applied Deep Learning Development
Stars: ✭ 259 (-50.76%)
Mutual labels:  artificial-intelligence, data-science, ml
Polyaxon
Machine Learning Platform for Kubernetes (MLOps tools for experimentation and automation)
Stars: ✭ 2,966 (+463.88%)
Mutual labels:  artificial-intelligence, data-science, ml
Datascience course
Curso de Data Science em Português
Stars: ✭ 294 (-44.11%)
Mutual labels:  artificial-intelligence, data-science, data-analysis
Hyperparameter hunter
Easy hyperparameter optimization and automatic result saving across machine learning algorithms and libraries
Stars: ✭ 648 (+23.19%)
Mutual labels:  artificial-intelligence, data-science, ml
Nfstream
NFStream: a Flexible Network Data Analysis Framework.
Stars: ✭ 622 (+18.25%)
Mutual labels:  artificial-intelligence, data-science, data-analysis
Datasciencevm
Tools and Docs on the Azure Data Science Virtual Machine (http://aka.ms/dsvm)
Stars: ✭ 153 (-70.91%)
Mutual labels:  data-science, data-analysis, ml
Csinva.github.io
Slides, paper notes, class notes, blog posts, and research on ML 📉, statistics 📊, and AI 🤖.
Stars: ✭ 342 (-34.98%)
Mutual labels:  artificial-intelligence, data-science, ml
Data Science Resources
👨🏽‍🏫You can learn about what data science is and why it's important in today's modern world. Are you interested in data science?🔋
Stars: ✭ 171 (-67.49%)
Mutual labels:  artificial-intelligence, data-science, data-analysis
Igel
a delightful machine learning tool that allows you to train, test, and use models without writing code
Stars: ✭ 2,956 (+461.98%)
Mutual labels:  artificial-intelligence, data-science, data-analysis
Ai Learn
人工智能学习路线图,整理近200个实战案例与项目,免费提供配套教材,零基础入门,就业实战!包括:Python,数学,机器学习,数据分析,深度学习,计算机视觉,自然语言处理,PyTorch tensorflow machine-learning,deep-learning data-analysis data-mining mathematics data-science artificial-intelligence python tensorflow tensorflow2 caffe keras pytorch algorithm numpy pandas matplotlib seaborn nlp cv等热门领域
Stars: ✭ 4,387 (+734.03%)
Mutual labels:  artificial-intelligence, data-science, data-analysis
Data Science
Collection of useful data science topics along with code and articles
Stars: ✭ 315 (-40.11%)
Mutual labels:  artificial-intelligence, data-science, data-analysis
Datascience Ai Machinelearning Resources
Alex Castrounis' curated set of resources for artificial intelligence (AI), machine learning, data science, internet of things (IoT), and more.
Stars: ✭ 414 (-21.29%)
Mutual labels:  artificial-intelligence, data-science

Rumale

Rumale

Build Status Coverage Status Gem Version BSD 2-Clause License Documentation

Rumale (Ruby machine learning) is a machine learning library in Ruby. Rumale provides machine learning algorithms with interfaces similar to Scikit-Learn in Python. Rumale supports Support Vector Machine, Logistic Regression, Ridge, Lasso, Multi-layer Perceptron, Naive Bayes, Decision Tree, Gradient Tree Boosting, Random Forest, K-Means, Gaussian Mixture Model, DBSCAN, Spectral Clustering, Mutidimensional Scaling, t-SNE, Fisher Discriminant Analysis, Neighbourhood Component Analysis, Principal Component Analysis, Non-negative Matrix Factorization, and many other algorithms.

Installation

Add this line to your application's Gemfile:

gem 'rumale'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rumale

Documentation

Usage

Example 1. Pendigits dataset classification

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

$ wget https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/multiclass/pendigits
$ wget https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/multiclass/pendigits.t

Training of the classifier with Linear SVM and RBF kernel feature map is the following code.

require 'rumale'

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

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

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

# Save the model.
File.open('transformer.dat', 'wb') { |f| f.write(Marshal.dump(transformer)) }
File.open('classifier.dat', 'wb') { |f| f.write(Marshal.dump(classifier)) }

Classifying testing data with the trained classifier is the following code.

require 'rumale'

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

# Load the model.
transformer = Marshal.load(File.binread('transformer.dat'))
classifier = Marshal.load(File.binread('classifier.dat'))

# Map testing data to RBF kernel feature space.
transformed = transformer.transform(samples)

# Classify the testing data and evaluate prediction results.
puts("Accuracy: %.1f%%" % (100.0 * classifier.score(transformed, labels)))

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

Execution of the above scripts result in the following.

$ ruby train.rb
$ ruby test.rb
Accuracy: 98.7%

Example 2. Cross-validation

require 'rumale'

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

# Define the estimator to be evaluated.
lr = Rumale::LinearModel::LogisticRegression.new

# Define the evaluation measure, splitting strategy, and cross validation.
ev = Rumale::EvaluationMeasure::Accuracy.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)

# Output result.
mean_accuracy = report[:test_score].sum / kf.n_splits
puts "5-CV mean accuracy: %.1f%%" % (100.0 * mean_accuracy)

Execution of the above scripts result in the following.

$ ruby cross_validation.rb
5-CV mean accuracy: 95.4%

Example 3. Pipeline

require 'rumale'

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

# Construct pipeline with kernel approximation and LogisticRegression.
rbf = Rumale::KernelApproximation::RBF.new(gamma: 1e-4, n_components: 800, random_seed: 1)
lr = Rumale::LinearModel::LogisticRegression.new(reg_param: 1e-3)
pipeline = Rumale::Pipeline::Pipeline.new(steps: { trns: rbf, clsf: lr })

# Define the splitting strategy and cross validation.
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)

# Output result.
mean_accuracy = report[:test_score].sum / kf.n_splits
puts("5-CV mean accuracy: %.1f %%" % (mean_accuracy * 100.0))

Execution of the above scripts result in the following.

$ ruby pipeline.rb
5-CV mean accuracy: 99.6 %

Speed up

Numo::Linalg

Rumale uses Numo::NArray for typed arrays. Loading the Numo::Linalg allows to perform matrix product of Numo::NArray using BLAS libraries. For example, using the OpenBLAS speeds up many estimators in Rumale.

Install OpenBLAS library.

macOS:

$ brew install openblas

Ubuntu:

$ sudo apt-get install libopenblas-dev liblapacke-dev

Windows (MSYS2):

$ pacman -S mingw-w64-x86_64-ruby mingw-w64-x86_64-openblas mingw-w64-x86_64-lapack

Install Numo::Linalg gem.

$ gem install numo-linalg

In ruby script, you only need to require the autoloader module of Numo::Linalg.

require 'numo/linalg/autoloader'
require 'rumale'

Numo::OpenBLAS

Numo::OpenBLAS downloads and builds OpenBLAS during installation and uses that as a background library for Numo::Linalg.

Install compilers for building OpenBLAS.

macOS:

$ brew install gcc gfortran make

Ubuntu:

$ sudo apt-get install gcc gfortran make

Install Numo::OpenBLAS gem.

$ gem install numo-openblas

Load Numo::OpenBLAS gem instead of Numo::Linalg.

require 'numo/openblas'
require 'rumale'

Parallel

Several estimators in Rumale support parallel processing. Parallel processing in Rumale is realized by Parallel gem, so install and load it.

$ gem install parallel
require 'parallel'
require 'rumale'

Estimators that support parallel processing have n_jobs parameter. When -1 is given to n_jobs parameter, all processors are used.

estimator = Rumale::Ensemble::RandomForestClassifier.new(n_jobs: -1, random_seed: 1)

Related Projects

  • Rumale::SVM provides support vector machine algorithms in LIBSVM and LIBLINEAR with Rumale interface.
  • Rumale::Torch provides the learning and inference by the neural network defined in torch.rb with Rumale interface.

Novelties

Contributing

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 code of conduct.

License

The gem is available as open source under the terms of the BSD 2-clause License.

Code of Conduct

Everyone interacting in the Rumale project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].