Framework
rust-ml/linfa avatar
rust-ml/linfa

linfa: eighteen Rust algorithm crates and an empty default feature list

A Rust machine learning framework.

4,770 stars334 forksRustApache-2.0

At a glance

What is it?
linfa is a Rust umbrella for classical machine learning that keeps every algorithm in its own crate under algorithms/. It covers the usual preprocessing and estimator families, and it leaves build configuration to Cargo.toml, where the default feature list is empty and the blas flag does nothing until you name a backend.
Who is it for?
linfa suits a Rust codebase that wants classical estimators and preprocessing steps under one dependency tree, and it suits you badly if your workload is neural network training, since none of the eighteen listed crates is a network crate. Check before committing by compiling the specific algorithm crates on your own platform, because the table records testing and benchmarking status but never states per-crate WebAssembly or platform support.
Can I use it commercially?
Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository received new commits within the last day.
What is it written in?
Mainly Rust, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 23, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • rust-ml/linfa4,770 ★ · +23
Star history
Repository2026-09-112026-11-23
rust-ml/linfa4.7k4.8k

23 Stars in the last 73 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

default = [] leaves every algorithm crate to you

The core crate ships nothing that trains a model. In Cargo.toml the features table opens with default = [] and then adds only switches for benchmarks, the BLAS backends, serde, and wasm-bindgen, so none of the features switches on an algorithm. Every algorithm lives in its own sub-package under algorithms/, named linfa-bayes, linfa-clustering, linfa-ensemble, linfa-elasticnet, linfa-ftrl, linfa-hierarchical, linfa-ica, linfa-kernel, linfa-lars, linfa-linear, linfa-logistic, linfa-nn, linfa-pls, linfa-preprocessing, linfa-reduction, linfa-svm, linfa-trees, and linfa-tsne, and you take only the ones your problem needs. The cost is that each algorithm crate you need has to be named in your own manifest. The name itself comes from the Italian word for sap, the fluid that circulates through a plant.

Five crates carry a Benchmarked label and no numbers

The status column separates crates that are merely tested from crates that have been benchmarked, and only five reach the second label: clustering for unlabeled data, ftrl for Follow The Regularized Leader with L1 and L2 regularization, nn for nearest neighbours and distance functions, preprocessing for normalization and whitening plus count vectorization and tf-idf, and trees for linear decision trees. The other thirteen, bayes through tsne, are listed as Tested and nothing more. Turning on the benchmarks feature adds criterion and pprof as dependencies, yet the README's status table gives no timings, input sizes, or results. So the label tells you a benchmark exists and not what it measured.

| Crate | Purpose | Status | | :--- | :--- | :--- | | clustering | Data clustering | Tested / Benchmarked | | ftrl | Follow The Regularized Leader - proximal | Tested / Benchmarked | | nn | Nearest Neighbours and Distances | Tested / Benchmarked | | preprocessing | Normalization and Vectorization | Tested / Benchmarked | | trees | Decision trees | Tested / Benchmarked |

blas only forwards, and only Intel MKL reaches macOS

Linear algebra routines come from a pure-Rust implementation by default. Enabling the blas feature on its own does not link a library: it forwards to ndarray/blas, and you still have to add a backend on top of it. The backend table is what narrows the choice. OpenBLAS and Netlib are marked for Linux only, with a dash under both Windows and macOS, while Intel MKL is marked in all three columns, which leaves anyone on a Mac or on Windows with intel-mkl-static or intel-mkl-system as the only external options. Each backend exists in two forms because one links the copy already installed on your system and the other statically builds it.

The second backend has two spellings and the flag example stops mid-sentence

The backend sentence names the three options as openblas, netblas, and intel-mkl, while the feature names in Cargo.toml for that second backend are netlib-static and netlib-system, and the support table spells the row Netlib. A reader who copies netblas straight out of that sentence gets a Cargo error about an unknown feature, and the fix is to notice that the manifest is the authority rather than the prose.

Browser support is one sentence and one feature flag

For browser-style WASM on wasm32-unknown-unknown the instruction is a single sentence: enable the wasm-bindgen feature, which the manifest defines as a wrapper around the optional getrandom dependency.

toml
serde = ["serde_crate", "ndarray/serde"]
wasm-bindgen = ["dep:getrandom"]

That is the whole documented story for browsers. The status table has no WebAssembly column, none of the eighteen crates is marked for a web target, and the benchmarked labels are silent about it too, so nothing tells you whether linfa-svm or linfa-clustering compile for a browser build. You find out by compiling, one crate at a time, and a failure there arrives after the dependency and backend choices are already made.

Datasets and generators sit in a path dependency, not in src/

The repository root is small: .github/, .gitignore, CHANGELOG.md, CONTRIBUTE.md, Cargo.toml, LICENSE-APACHE2, LICENSE-MIT, README.md, algorithms/, build.rs, datasets/, docs/, mascot.svg, and src/. Everything you would look for when hunting for estimators is under algorithms/, and the example data arrives through a path dependency on datasets rather than from src/.

toml
linfa-datasets = { path = "datasets", features = [
    "winequality",
    "iris",
    "diabetes",
    "generate",
] }

Those four features are what make the wine quality, iris, and diabetes tables and a synthetic data generator available to tests and examples, and ndarray-rand 0.15 sits alongside them as a dev-dependency for generating rows. build.rs at the root means part of the build does compile-time work, and the README links rendered API documentation on the project's site at rust-ml.github.io/linfa.

sprs is pinned to one exact patch release

The sparse matrix dependency is pinned with an equals sign, and its default features are switched off.

toml
ndarray = { version = "0.16", features = ["approx"] }
ndarray-linalg = { version = "0.17", optional = true }
sprs = { version = "=0.11.2", default-features = false }
thiserror = "2.0"

That pin means linfa's manifest will not float to a newer patch of the sparse matrix library, and it takes the crate with default features disabled rather than as its authors intended. If your own tree needs a different 0.11.x build or a newer line, you resolve it by patching rather than by upgrading, and the patch becomes yours to carry. Version numbers point the same way from the other side: the manifest declares 0.8.1 on edition 2018, the 0.8.1 release is dated 2025-12-23 after 0.8.0 on 2025-09-30 and 0.7.1 on 2025-01-17, and the last commit on the default master branch is dated 2026-08-22, so anything merged since December 2025 is not in what crates.io serves you.

Editorial conclusion

linfa suits a Rust codebase that wants classical estimators and preprocessing steps under one dependency tree, and it suits you badly if your workload is neural network training, since none of the eighteen listed crates is a network crate. Check before committing by compiling the specific algorithm crates on your own platform, because the table records testing and benchmarking status but never states per-crate WebAssembly or platform support.

Frequently asked questions

How many algorithms does linfa ship, and how do you get them?

The framework is split into eighteen algorithm crates under algorithms/, from linfa-bayes through linfa-tsne. The root crate lists default = [] in its features, so the algorithm crates you want have to be named in your own manifest.

Does linfa require a BLAS or LAPACK library to build?

No. A pure-Rust implementation is used by default, and the blas feature on its own only forwards to ndarray/blas. You must also pick a backend, openblas, netblas, or intel-mkl as the prose names them, each in a static and a system variant, and only Intel MKL is marked as available on Windows and macOS as well as Linux.

Can linfa run in a browser with WebAssembly?

The documented route is the wasm-bindgen feature on wasm32-unknown-unknown, defined in the manifest as a wrapper around the optional getrandom dependency. No per-crate WebAssembly status is given for the eighteen algorithm crates.

Which datasets come with linfa for tests and examples?

The datasets crate is pulled in as a path dependency with the winequality, iris, diabetes, and generate features, so those three tables and a synthetic generator are available. The tables come from that crate, not from the root crate.

How recent is the last change to linfa?

The repository is not archived, and the last commit on the default master branch is dated 2026-08-22. The newest published release is 0.8.1 from 2025-12-23, which follows 0.8.0 on 2025-09-30 and 0.7.1 on 2025-01-17.

Official sources

  1. Issues
  2. License: Apache-2.0
  3. README
  4. Releases
  5. rust-ml/linfa on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/rust-ml-linfa.svg)](https://hysenlabs.com/projects/rust-ml-linfa)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/rust-ml-linfa.svg)](https://hysenlabs.com/projects/rust-ml-linfa)

Was this useful?