Ruby ML for Python Coders

Python and Ruby

Curious to try machine learning in Ruby? Here’s a short cheatsheet for Python coders.

Data structure basics

Libraries

Category Python Ruby
Multi-dimensional arrays NumPy Numo
Data frames Pandas Daru
Visualization Matplotlib Nyaplot
Predictive modeling Scikit-learn Rumale
Gradient boosting XGBoost, LightGBM XGBoost, LightGBM
Deep learning PyTorch, TensorFlow Torch.rb, TensorFlow (TensorFlow construction)
Recommendations Surprise, Implicit Disco
Approximate nearest neighbors NGT, Faiss, Annoy NGT, Faiss, Hanny
Factorization machines xLearn xLearn
Natural language processing spaCy, NTLK Many gems (nothing comprehensive cry)
Text tokenization Bling Fire, YouTokenToMe Bling Fire, YouTokenToMe
Text classification fastText fastText
Forecasting Prophet Prophet.rb
Optimization OR-Tools, CVXPY, PuLP, SCS, OSQP OR-Tools, CBC, SCS, OSQP
Reinforcement learning Vowpal Wabbit Vowpal Wabbit
Bayesian inference PyStan, CmdStanPy CmdStan.rb
t-SNE Multicore t-SNE t-SNE
CUDA arrays CuPy Cumo
Scoring engine ONNX Runtime ONNX Runtime, Menoh

This list is by no means comprehensive. Many Ruby libraries are ones I created, as mentioned here.

If you’re planning to add Ruby support to your ML library:

Category Python Ruby
FFI (native) ctypes Fiddle
FFI (library) cffi FFI
C++ extensions pybind11 Rice
Compile to C Cython Rubex

Give Ruby a shot for your next maching learning project!

Updates

Published January 23, 2020 · Tweet

Ruby logo is licensed under CC BY-SA 2.5.


You might also enjoy

16 New ML Gems for Ruby

Gem Patterns

Why and How to Keep Your Decryption Keys Off Web Servers


All code examples are public domain.
Use them however you’d like (licensed under CC0).