Home

Awesome

<img align="left" src="./mascot.svg" width="70px" height="70px" alt="Linfa mascot icon">

Linfa

crates.io Documentation DocumentationLatest Codequality Run Tests

linfa (Italian) / sap (English):

The vital circulating fluid of a plant.

linfa aims to provide a comprehensive toolkit to build Machine Learning applications with Rust.

Kin in spirit to Python's scikit-learn, it focuses on common preprocessing tasks and classical ML algorithms for your everyday ML tasks.

<strong> <a href="https://rust-ml.github.io/linfa/">Website</a> | <a href="https://rust-ml.zulipchat.com">Community chat</a> </strong>

Current state

Where does linfa stand right now? Are we learning yet?

linfa currently provides sub-packages with the following algorithms:

NamePurposeStatusCategoryNotes
clusteringData clusteringTested / BenchmarkedUnsupervised learningClustering of unlabeled data; contains K-Means, Gaussian-Mixture-Model, DBSCAN and OPTICS
kernelKernel methods for data transformationTestedPre-processingMaps feature vector into higher-dimensional space
linearLinear regressionTestedPartial fitContains Ordinary Least Squares (OLS), Generalized Linear Models (GLM)
elasticnetElastic NetTestedSupervised learningLinear regression with elastic net constraints
logisticLogistic regressionTestedPartial fitBuilds two-class logistic regression models
reductionDimensionality reductionTestedPre-processingDiffusion mapping and Principal Component Analysis (PCA)
treesDecision treesTested / BenchmarkedSupervised learningLinear decision trees
svmSupport Vector MachinesTestedSupervised learningClassification or regression analysis of labeled datasets
hierarchicalAgglomerative hierarchical clusteringTestedUnsupervised learningCluster and build hierarchy of clusters
bayesNaive BayesTestedSupervised learningContains Gaussian Naive Bayes
icaIndependent component analysisTestedUnsupervised learningContains FastICA implementation
plsPartial Least SquaresTestedSupervised learningContains PLS estimators for dimensionality reduction and regression
tsneDimensionality reductionTestedUnsupervised learningContains exact solution and Barnes-Hut approximation t-SNE
preprocessingNormalization & VectorizationTested / BenchmarkedPre-processingContains data normalization/whitening and count vectorization/tf-idf
nnNearest Neighbours & DistancesTested / BenchmarkedPre-processingSpatial index structures and distance functions
ftrlFollow The Regularized Leader - proximalTested / BenchmarkedPartial fitContains L1 and L2 regularization. Possible incremental update

We believe that only a significant community effort can nurture, build, and sustain a machine learning ecosystem in Rust - there is no other way forward.

If this strikes a chord with you, please take a look at the roadmap and get involved!

BLAS/Lapack backend

Some algorithm crates need to use an external library for linear algebra routines. By default, we use a pure-Rust implementation. However, you can also choose an external BLAS/LAPACK backend library instead, by enabling the blas feature and a feature corresponding to your BLAS backend. Currently you can choose between the following BLAS/LAPACK backends: openblas, netblas or intel-mkl.

BackendLinuxWindowsmacOS
OpenBLAS✔️--
Netlib✔️--
Intel MKL✔️✔️✔️

Each BLAS backend has two features available. The feature allows you to choose between linking the BLAS library in your system or statically building the library. For example, the features for the intel-mkl backend are intel-mkl-static and intel-mkl-system.

An example set of Cargo flags for enabling the Intel MKL backend on an algorithm crate is --features blas,linfa/intel-mkl-system. Note that the BLAS backend features are defined on the linfa crate, and should only be specified for the final executable.

License

Dual-licensed to be compatible with the Rust project.

Licensed under the Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0 or the MIT license http://opensource.org/licenses/MIT, at your option. This file may not be copied, modified, or distributed except according to those terms.