Ruby ML for Python Coders
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, Rover |
| Visualization | Altair | Vega |
| Predictive modeling | Scikit-learn | Rumale |
| Gradient boosting | XGBoost, LightGBM | XGBoost, LightGBM |
| Deep learning | PyTorch, TensorFlow | Torch.rb, TensorFlow (TensorFlow |
| 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!
Updates
- March-May 2020: Added more gems
- September-October 2020: Added more gems