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


Category Python Ruby
Multi-dimensional arrays NumPy Numo
Data frames Pandas Daru, Rover
Visualization Altair Vega
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, Annoy.rb
Factorization machines xLearn xLearn
Natural language processing Transformers, spaCy, NTLK Informers, many others
Text tokenization Bling Fire, YouTokenToMe Bling Fire, YouTokenToMe
Text classification fastText fastText
Topic modeling Gemsim, tomotopy tomoto
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 and 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!


Published January 23, 2020

Ruby logo is licensed under CC BY-SA 2.5.

You might also enjoy

Rails, Meet Data Science

15 More ML Gems for Ruby

Numo: NumPy for Ruby

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