smartcorelib/smartcore
A comprehensive library for machine learning and numerical computing. Apply Machine Learning with Rust leveraging first principles.
What it solves
smartcore addresses the need for a production-friendly machine learning library in Rust. It provides classical supervised and unsupervised algorithms with strong typing and good defaults, so developers can build and deploy ML models without leaving the Rust ecosystem. The library also aims to be ergonomic, making it approachable for research and experimentation while remaining practical for production use.
How it works
smartcore organizes algorithms into clear modules with consistent traits. It uses a modular linear algebra abstraction with optional ndarray support, and defaults to a WASM-first posture for portability. Algorithms include linear models (OLS, Ridge, Lasso, ElasticNet, Logistic Regression), tree-based methods (Random Forest, Extra Trees), SVMs, KNN, clustering (K-Means, DBSCAN, agglomerative), decomposition (SVD, EVD, etc.), and preprocessing utilities. Users interact through a consistent API—for example, fitting a KNN classifier involves creating a DenseMatrix from vectors and callingfit with default parameters. The library includes optional features like dataset generators, CSV readers, and a lazy-normalization mode to reduce memory usage in Lasso and ElasticNet. The README highlights a trait-system refactor that favors object-safe traits and fewer structs, and the library has moved to the Rust 2024 edition (MSRV 1.85).
Who it’s for
smartcore targets Rust developers who need classical machine learning algorithms in a strongly typed, efficient language. It suits both production use (with stable APIs and good defaults) and research or experimentation (via Jupyter notebooks and flexible features). The WASM-first approach makes it appealing for browser and embedded deployments, and the optional ndarray integration appeals to developers who prefer array-first workflows.
Highlights
- Broad coverage: linear models, trees, ensembles, SVMs, neighbors, clustering, decomposition, and preprocessing.
- Strong linear algebra traits with optional ndarray integration.
- WASM-first defaults and opt-in features (serde, datasets) for portability and minimal footprint.
- Practical utilities: model selection, evaluation, CSV readers, dataset generators, built-in datasets.
- Recent additions: XGBoost-style regression, single-linkage clustering, Extra Trees, and multiclass SVM improvements.
- Live benchmark charts (criterion wall-clock and iai-callgrind instruction counts) published on GitHub Pages to track performance trends.
Related
- Project
- Project
- Project
- Project
- Project