rustyml
Library Listed
Machine learning models, neural networks, metrics, and data utilities in Rust
- Downloads
- 59
- Dependents
- 0
- Stars
- 345
- Forks
- 65
- Contributors
- 1
- Commits
- 659
- Latest release
- 0.17.0 ·
About
A machine learning and deep learning library written in pure Rust.
Read the RustyML User Guide for instructions and examples.
Overview
RustyML provides data preprocessing, machine learning models, neural networks, and evaluation metrics.
It uses ndarray arrays and Rust numeric kernels.
Features
- Parallel kernels: selected kernels use Rayon. Work thresholds control the choice between serial and parallel paths.
- Models: supervised learning, unsupervised learning, anomaly detection, sequential networks, and graph networks.
- Random seeds:
set_global_seedsets a seed stream on the calling thread. Localrandom_statevalues override that stream where supported. - Binary files: supported models use Serde and postcard to save and load fitted state.
- Network checkpoints: save model arrays, then load them into a compatible built model. Checkpoints do not restore the optimizer or loss.
- Metrics: regression, binary classification, multiclass classification, and clustering. Read each metric's input rules and score definition.
Reset the global seed before repeating the same sequence of random operations. Other threads have separate seed streams. Some decomposition solvers use independent seeds.
Read the full README
Installation
Add RustyML to your Cargo.toml:
[dependencies]
rustyml = "0.17.0"
ndarray = "0.17"
Disable default features to select individual modules:
# Everything (ml, nn, utils, metrics, math)
rustyml = "0.17.0"
# Just the neural-network framework
rustyml = { version = "0.17.0", default-features = false, features = ["neural_network"] }
# Just the evaluation metrics
rustyml = { version = "0.17.0", default-features = false, features = ["metrics"] }
# Show training progress bars in the terminal
rustyml = { version = "0.17.0", features = ["show_progress"] }
MSRV: Rust 1.89+ (edition 2024).
Quick Start
Classical Machine Learning
use rustyml::prelude::machine_learning::*;
use ndarray::array;
fn main() {
// Train a linear regression model without regularization.
let mut model = LinearRegression::new(true)
.with_solver(LeastSquaresSolver::GradientDescent { learning_rate: 0.01, max_iter: 1000, tol: 1e-6 }).unwrap();
let x = array![[1.0, 2.0], [2.0, 3.0], [3.0, 4.0]];
let y = array![6.0, 9.0, 12.0];
model.fit(&x, &y).unwrap();
let predictions = model.predict(&x).unwrap();
println!("{:?}", predictions);
// Save and reload the trained model.
model.save_to_path("linear_regression.bin").unwrap();
let restored = LinearRegression::load_from_path("linear_regression.bin").unwrap();
}
Neural Networks
use rustyml::prelude::neural_network::*;
use ndarray::Array;
fn main() {
// 32 samples, 784 input features, 10 output classes
let x = Array::ones((32, 784)).into_dyn();
let mut y = Array::zeros((32, 10));
y.column_mut(0).fill(1.0);
let y = y.into_dyn();
// Build the layers from the input shape.
let mut model = SequentialBuilder::new()
.add(Dense::new(128, Activation::ReLU).unwrap())
.add(Dense::new(64, Activation::ReLU).unwrap())
.add(Dense::new(10, Activation::Softmax { axis: -1 }).unwrap())
.build(&Shape::known(x.shape()))
.unwrap();
model.compile(
Adam::new(0.001, 0.9, 0.999, 1e-8, 0.0).unwrap(),
CategoricalCrossEntropy::new(false),
);
model.summary(); // Print the model structure.
// Record 1 loss value during each epoch.
let history = model.fit(&x, &y, 10).unwrap();
println!("Per-epoch loss: {:?}", history.loss());
// Evaluate the current weights in inference mode.
println!("Loss after training: {}", model.evaluate(&x, &y).unwrap());
let predictions = model.predict(&x).unwrap();
println!("Predictions shape: {:?}", predictions.shape());
// Save all model arrays to a file.
model.save_to_path("model.bin").unwrap();
}
Graph Models
A sequential model passes each layer's output to the next layer.
GraphBuilder connects layer calls as nodes in a graph.
A graph can have multiple inputs, multiple outputs, shared layers, and residual connections.
The merge layers join branches: Add, Subtract, Multiply, Average, Maximum, Minimum, and Concatenate.
use rustyml::prelude::neural_network::*;
use ndarray::Array;
fn main() {
// 4 samples of 8 features, and 2 output values per sample
let x = Array::ones((4, 8)).into_dyn();
let y = Array::ones((4, 2)).into_dyn();
// A residual block: the input of the block reaches the sum and the hidden layer alike
let mut builder = GraphBuilder::new();
let input = builder.input(Shape::known(&[4, 8]));
let hidden = builder.add(Dense::new(8, Activation::ReLU).unwrap(), &[input]);
let sum = builder.add(Add::new(), &[input, hidden]);
let head = builder.add(Dense::new(2, Activation::Linear).unwrap(), &[sum]);
let mut model = builder.build(&[head]).unwrap();
model.compile(
SGD::new(0.01, 0.0, false, 0.0).unwrap(),
MeanSquaredError::new(),
);
// 1 tensor per inlet, and 1 target per outlet
model.fit(&[&x], &[&y], 10).unwrap();
let predictions = model.predict(&[&x]).unwrap();
println!("Predictions shape: {:?}", predictions[0].shape());
}
Evaluating a Model
use rustyml::metrics::*;
use ndarray::array;
fn main() {
// Pass the true labels before the predicted labels.
// Use hard 0.0/1.0 labels here. Use new_with_labels for other label pairs.
let y_true = array![1.0, 0.0, 0.0, 1.0, 1.0];
let y_pred = array![1.0, 0.0, 1.0, 1.0, 0.0];
// The arguments can use an owned array and a view.
let cm = ConfusionMatrix::new(&y_true, &y_pred.view());
println!("Accuracy: {:.3}", cm.accuracy());
println!("F1 score: {:.3}", cm.f1_score());
}
Modules
The public modules group the API by task:
machine_learning: estimators for classification, regression, clustering, decomposition, and anomaly detection.neural_network: layers, model builders, losses, optimizers, and checkpoints.utils: preprocessing, label conversion, scalers, and dataset splits.metrics: classification, regression, and clustering scores.math: distance functions, matrix operations, and reductions.error: shared error types and result aliases.random: thread-local seed controls.traits: common estimator contracts.tuning: runtime thresholds for serial and parallel work.prelude: grouped imports for public types and traits.
See the API reference.
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. Minor releases can change the API 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.
Compatibility
- Runs on
- GPU support unknown
What shows it
- no dependency or feature matches a backend row
- Native code
- None found
- No native code found
- Python bindings
- No Python binding crate found
- License
- MIT
Compare with similar projects
Order: strongest tier first, then most downloads, then name, with unmeasured values last. A library counts downloads over 30 days. An app counts binary downloads per release. An app with none counts its crate downloads over 30 days. ML Rust runs this catalogue, so its closest project always gets a row.
| Project | Downloads | Dependents | Stars | Latest release | Runs on (GPU) | Native code | License |
|---|---|---|---|---|---|---|---|
|
Machine learning models, neural networks, metrics, and data utilities in Rust |
59 downloads over 30 days | 0 | 345 | 0.17.0 | GPU support unknown | No native code found | MIT |
|
burn Featured
Flexible and Comprehensive Deep Learning Framework in Rust |
521,465 downloads over 30 days | 391 | 16,257 | 0.22.1 | CUDA, WebGPU, Metal, ROCm, Vulkan | Binds native code: netlink-sys (feature iroh), nvml-wrapper-sys (feature sys-metrics), torch-sys (feature tch) | Apache-2.0 OR MIT |
|
mlx-rs Featured
Unofficial rust wrapper for Apple's mlx machine learning library. |
33,398 downloads over 30 days | 36 | 389 | 0.34.0 | Metal | Binds native code: mach-sys, mlx, mlx-sys. Build uses a native toolchain: bindgen, cc, cmake | Apache-2.0 OR MIT |
|
rumus Listed
A native-Rust deep learning framework with explicit memory safety and hardware acceleration |
52 downloads over 30 days | 0 | 202 | 0.4.0 | WebGPU | No native code found | Apache-2.0 OR MIT |
|
Trains GPT-style language models from a YAML config and a tokenized dataset: dense GQA transformers, Mamba 1, 2 and 3, MLA and MoE layers on CPU or CUDA. Runs the training loop, optimizer, checkpoints, evaluation and metrics on boostr, and builds speech corpora through voxr. |
27 downloads over 30 days | Not applicable | 8 | 0.1.1 | CUDA | Binds native code: nvml-wrapper-sys (feature cuda) | Apache-2.0 |
|
HAL: a machine learning library that is able to run on Nvidia, OpenCL or CPU BLAS based compute backends. It currently provides stackable classical neural networks, RNN's and soon to be LSTM's. |
2 downloads over 30 days | 0 | 92 | 0.2.0 | GPU support unknown | No native code found | BSD-3-Clause |
Why ListedNo archive, New or Featured rule places it, so it is Listed.
What it lacks for Featured
- It has 0 active dependents and 0 new dependents in 365 days. Featured needs 11 active dependents or 9 new dependents in 365 days. The repository route reads 345 stars, 65 forks and 1 contributor. It needs 4,539 stars, 434 forks and 79 contributors together.
What else the check found
- The last activity is on 28 Oct 2026, 12 days ago. The rules expect an update within 365 days. Dormancy rule
Exact rules: Listed, Featured library. The check on applied thresholds version 9.
Every rule outcome, as the check records it
expected-interval: version 0.17.0 base 140, raised to the 365-day floor: E = 365 daysdormancy: last activity 2026-10-28, 12 days ago, E = 365: activefeatured: not featured: active_users 0 < 11 and new_adopters 0 < 9 and repository route stars 345 (needs 4539), forks 65 (needs 434), contributors 1 (needs 79)listed: listed: no archive, new or featured rule applies
Measurements and sources
Each signal row shows the raw value, its source and the fetch date. The Sources list gathers every distinct source on this page. Movement needs more history.
Sources6 sources
- Description: the crates.io description
- crates.io database dump, fetched
- RustSec advisory database, fetched
- GitHub repository, fetched
- crates.io package, fetched
- GitHub contributors, fetched
Adoption0 active dependents, 0 new dependents in 365 days1 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Active dependents | 0 | crates.io database dump | Yes | |
| New dependents (365 days) | 0 | crates.io database dump | Yes | |
| Peak active dependents | 1 | crates.io database dump | Yes | |
| Active dependents as a share of the peak | 1 | crates.io database dump | Yes | |
| Binary downloads per release | Not measured | Yes |
MaintenanceLatest human commit: 13 days ago3 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Latest human commit | 2026-10-27 | GitHub repository | Yes | |
| Latest release | 2026-10-28 | crates.io database dump | Yes | |
| First release | 2025-03-31 | crates.io database dump | Yes | |
| Latest version | 0.17.0 | crates.io database dump | Yes | |
| Days the oldest outside issue waits for a reply | 0 | GitHub repository | Yes | |
| Maintainer replies over 365 days | 0 | GitHub repository | Yes | |
| Repository archived | false | GitHub repository | Yes | |
| Repository gone | false | GitHub repository | Yes | |
| Release commit or manifest in the repo | true | crates.io package | Yes | |
| Published docs | true | crates.io database dump | Yes | |
| Latest release fails cargo check | Not measured | Yes | ||
| Build check date | Not measured | Yes | ||
| Build check toolchain | Not measured | Yes |
SecurityUnpatched vulnerabilities: none
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Unpatched vulnerabilities past the grace window | none | RustSec advisory database | Yes | |
| RustSec unmaintained advisory | none | RustSec advisory database | Yes | |
| Deprecation notice | none | crates.io database dump | Yes | |
| Deprecated requirement | none | crates.io database dump | Yes |
Distribution24 releases, 59 downloads over 30 days5 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Releases | 24 | crates.io database dump | Yes | |
| Downloads over 30 days | 59 | crates.io database dump | Yes | |
| Binary downloads over the last 3 releases | Not measured | Yes | ||
| Homebrew installs on request over 365 days | Not measured | Yes | ||
| Repology repository families | Not measured | Yes | ||
| Docker pull growth over 90 days | Not measured | Yes | ||
| Docker pulls at the growth baseline | Not measured | Yes | ||
| Every version a prerelease | false | crates.io database dump | Yes | |
| Every version 0.0.x | false | crates.io database dump | Yes | |
| Every version yanked | false | crates.io database dump | Yes | |
| Crate deleted from crates.io | false | crates.io database dump | Yes |
Repository345 stars, 65 forks, 1 contributors, 659 commits. Stars alone never qualify a project.
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| GitHub stars | 345 | GitHub repository | Yes — one part of the repository route | |
| GitHub forks | 65 | GitHub repository | Yes — one part of the repository route | |
| Contributors with a GitHub account | 1 | GitHub contributors | Yes — one part of the repository route | |
| Commits on the default branch | 659 | GitHub repository | No | |
| Repository's main crate left out of the entry | none | crates.io database dump | Yes |
Facts that never count
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| License | MIT | crates.io database dump | No | |
| Runs on, from listed crates and their direct dependencies | GPU support unknown | crates.io database dump | No | |
| What shows each backend | no dependency or feature matches a backend row | crates.io database dump | No | |
| Native code, from listed crates and their dependencies | No native code found | crates.io database dump | No | |
| Python bindings, from direct dependencies of listed crates | No Python binding crate found | crates.io database dump | No | |
| Crates that depend on a listed crate directly | 0 | crates.io database dump | No |
Corrections and review history
No correction applies to this entry.
Judgments
A judgment enters only through an approved issue and a merged pull request.
No judgment applies to this entry.