RustyML
A machine learning and deep learning library written in pure Rust.
Read RustyML User Guide for detailed documentation and tutorials of RustyML.
Overview
RustyML is a machine learning and deep learning library, built end to end in Rust with no C or C++ dependencies. It covers the full workflow: data preprocessing, feature engineering, model training, and evaluation. It uses Rust's memory safety, safe concurrency, and zero-cost abstractions.
Highlights
- Pure Rust, no FFI: memory-safe and portable, with nothing to link against.
- Parallelized by default: heavy kernels use Rayon for multi-threaded computation.
- Algorithm coverage: classical supervised and unsupervised learning, anomaly detection, and a neural-network framework.
- Reproducible: a single
set_global_seedcall makes every randomized component on the calling thread deterministic. A per-componentrandom_statecovers the rest. - Model persistence: save and load trained models and network weights as compact binary, using Serde and postcard.
- Evaluation metrics: regression, classification (binary and multiclass), and clustering, matching scikit-learn conventions.
Installation
Add RustyML to your Cargo.toml:
[]
= "*"
= "0.17"
To slim the build, opt out of the default and name what you need:
# Everything (ml, nn, utils, metrics, math)
= "*"
# Just the neural-network framework
= { = "*", = false, = ["neural_network"] }
# Just the evaluation metrics
= { = "*", = false, = ["metrics"] }
# Show training progress bars in the terminal
= { = "*", = ["show_progress"] }
MSRV: Rust 1.89+ (edition 2024).
Quick Start
Classical Machine Learning
use *;
use array;
Neural Networks
use *;
use Array;
Evaluating a Model
use *;
use array;
Modules
See at docs.rs
Feature Flags
The crate uses feature flags for modular compilation:
| Feature | Description |
|---|---|
machine_learning |
Classical ML algorithms (enables math) |
neural_network |
Neural-network framework (enables math) |
utils |
Data preprocessing and dataset splitting (enables math) |
metrics |
Evaluation metrics (enables math) |
math |
Numerical primitives (distances, matrix products, parallel reductions) |
full |
All of the above modules |
default |
full |
show_progress |
Render training/iteration progress bars in the terminal |
Project Status
RustyML is under active development. The API is stabilizing, but breaking changes can still
appear in minor releases before 1.0.0.
Contributing
Contributions are welcome. To help build the Rust ML library, you can:
- Open issues for bugs or feature requests
- Submit pull requests for improvements
- Share feedback on the API design
- Improve the documentation and examples
Please also review the Code of Conduct.
Author
SomeB1oody (stanyin64@gmail.com)
License
The MIT License covers this project. See the LICENSE file for details.