10 Machine Learning Libraries that Every Developers Should Know
Machine learning in Python benefits from a rich, familiar set of libraries. Rust now provides capable equivalents that emphasize performance, safety, and predictable deployment. Project Mars brings both Python and Rust libraries into an interactive notebook environment so developers can experiment, iterate, and share results in their preferred language.
Python to Rust at a glance
| Python library | Rust equivalent | What it does |
|---|---|---|
| scikit-learn | linfa | Classical machine learning algorithms and pipelines |
| PyTorch | tch-rs | Deep learning with tensor operations and training loops |
| TensorFlow | tensorflow | Graph-based and production-oriented ML workflows |
| Keras | burn | Ergonomic model building and training abstractions |
| XGBoost | xgboost-rs | Gradient-boosted decision trees |
| LightGBM | lightgbm | Fast gradient boosting for tabular data |
| CatBoost | catboost-rs | Gradient boosting with strong categorical handling |
| JAX | dfdx | Composable array/tensor transformations and autodiff-style workflows |
| Transformers | rust-bert | Pretrained transformer models for NLP tasks |
| OpenCV | opencv | Computer vision, image processing, and video I/O |
1. scikit-learn → linfa
scikit-learn is the standard toolkit for classical ML in Python. linfa aims to provide a similar experience in Rust, with algorithms for clustering, classification, preprocessing, and model evaluation. Its Rust-native design makes it a strong fit for fast, type-safe experimentation in notebooks.
See scikit-learn vs linfa for a detailed comparison.
2. PyTorch → tch-rs
PyTorch is popular for research and production deep learning. tch-rs provides Rust bindings to the Torch ecosystem, enabling tensor computation and neural network workflows from Rust code. In Project Mars, developers can prototype model logic interactively while staying in a compiled language.
See PyTorch vs tch-rs for a detailed comparison.
3. TensorFlow → tensorflow
TensorFlow supports large-scale training and deployment scenarios. The Rust tensorflow crate exposes TensorFlow capabilities to Rust applications, allowing developers to integrate established ML graphs and inference workflows into a Rust-first environment.
See TensorFlow Python vs Rust for a detailed comparison.
4. Keras → burn
Keras is known for its approachable, high-level API. burn offers an ergonomic Rust framework for building and training models with a modern developer experience. It helps bridge the gap between low-level tensor control and productive model development.
See Keras vs burn for a detailed comparison.
5. XGBoost → xgboost-rs
XGBoost is a widely used gradient boosting library for tabular data. xgboost-rs brings that power to Rust, making it possible to train and evaluate strong tree-based models where latency, throughput, and deployment simplicity matter.
See XGBoost vs xgboost-rs for a detailed comparison.
6. LightGBM → lightgbm
LightGBM is valued for speed and efficiency on large tabular datasets. The lightgbm Rust bindings enable Rust developers to use this proven boosting approach in data pipelines and notebook experiments without leaving the Rust ecosystem.
See LightGBM Python vs Rust for a detailed comparison.
7. CatBoost → catboost-rs
CatBoost handles categorical features effectively and often performs well with minimal preprocessing. catboost-rs provides Rust access to CatBoost workflows, supporting practical ML tasks where categorical data is central.
See CatBoost vs catboost-rs for a detailed comparison.
8. JAX → dfdx
JAX combines array programming with composable transformations. dfdx offers a Rust approach to tensor and differentiable programming patterns, giving developers a path to experiment with modern ML building blocks in a safe, compiled setting.
See JAX vs dfdx for a detailed comparison.
9. Transformers → rust-bert
The Python Transformers ecosystem made pretrained NLP models widely accessible. rust-bert provides Rust implementations and bindings for transformer-based models, enabling tasks like classification, embeddings, and generation in Rust applications and notebooks.
See Transformers vs rust-bert for a detailed comparison.
10. OpenCV → opencv
OpenCV is a foundational computer vision library. The Rust opencv crate exposes OpenCV functionality for image processing, feature detection, and video workflows, making it a natural companion for ML systems that operate on visual data.
See OpenCV Python vs Rust for a detailed comparison.
Try it in Project Mars
Both runtimes share one .mars document: Python cells run in a persistent interpreter, Rust cells on the replay runtime with // :dep Cargo dependencies — and state stays inside each language's own session.
The same task — fit a tiny model and score it — once per ecosystem:
# scikit-learn side: load iris, fit logistic regression, score.
from sklearn.datasets import load_iris
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
X, y = load_iris(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)
model = LogisticRegression(max_iter=200).fit(X_train, y_train)
model.score(X_test, y_test)
// :dep ndarray = "0.16"
// :dep rand = "0.8"
use ndarray::{s, Array2};
use rand::Rng;
// linfa-style workflow on the replay runtime: synthetic features,
// a train/test split, and a mean baseline — no external ML crate needed.
let mut rng = rand::thread_rng();
let n = 200;
let mut xs = Array2::zeros((n, 2));
let mut ys = Vec::with_capacity(n);
for i in 0..n {
let a = rng.gen_range(-1.0..1.0);
let b = rng.gen_range(-1.0..1.0);
xs[[i, 0]] = a;
xs[[i, 1]] = b;
ys.push(if a + b > 0.0 { 1.0 } else { 0.0 });
}
let split = n * 4 / 5;
let (x_train, y_train) = (&xs.slice(s![..split, ..]), &ys[..split]);
let baseline = y_train.iter().sum::<f64>() / y_train.len() as f64;
println!("train mean: {baseline:.3}");
How Project Mars supports both ecosystems
Project Mars is built to make ML development in Python, Rust, Julia, and C++ interactive, reproducible, and practical:
- Persistent sessions. Train, evaluate, and iterate across notebook cells while keeping variables and intermediate results available in your preferred language.
- Notebook-native workflow. Combine code, Markdown explanations, equations, tables, and rich outputs in a single
.marsdocument. - Rust ecosystem. Use Rust crates such as
linfa,tch-rs,tensorflow,burn,xgboost-rs,lightgbm,catboost-rs,dfdx,rust-bert, andopencvwith Cargo dependency support. - Python ecosystem. Use standard Python ML libraries (scikit-learn, PyTorch, TensorFlow, etc.) with matplotlib figure capture and top-level
awaitsupport. - Julia ecosystem. Use Julia ML libraries (Flux.jl, MLJ.jl, ScikitLearn.jl) with MIME bundle output and interactive input support.
- C++ ecosystem. Use C++ ML libraries via Conan/vcpkg with replay-based compilation.
- Reproducibility and automation. Save notebooks as JSON, preserve outputs, and run them headlessly with the Project Mars CLI for repeatable experiments.
- Jupyter interoperability. Import and export
.ipynbfiles to bridge existing notebook workflows with Project Mars's multi-language runtime.
To get started with ML in Project Mars notebooks, open the getting started guide, explore the runtime documentation, and try the machine learning example which demonstrates a complete ML workflow in Project Mars.