linfa

repository·master·Indexed 26 days ago

https://github.com/rust-ml/linfa

A comprehensive machine learning framework for Rust, providing a collection of sub-packages for classical ML algorithms and preprocessing similar to scikit-learn. Version 0.8.1 includes implementations for Naive Bayes (Gaussian, Multinomial, Bernoulli), Elastic Net linear regression, Ensemble Learning (bagging), Follow The Regularized Leader (Ftrl) for CTR prediction, agglomerative hierarchical clustering, and kernel methods for dimensionality expansion.

Tokens
44.6K
Snippets
87
Records
283
Agent score
88%

What's inside linfa

  1. Overview of linfa-tsne implementation

    master

    linfa-tsne is a pure Rust implementation of t-Distributed Stochastic Neighbor Embedding (t-SNE) within the linfa machine learning ecosystem. It currently supports two methods:

    • exact solution t-SNE
    • Barnes-Hut t-SNE (which wraps the bhtsne crate)

    For performance optimization, refer to the main linfa documentation regarding available BLAS/LAPACK backends.

  2. Overview of linfa-kernel

    master
    linfa-kernel is a crate within the linfa ecosystem designed for dimensionality expansion in machine learning. It provides implementations of kernel functions that map features to higher-dimensional target spaces, which is a core component for algorithms like Support Vector Machines (SVM).
  3. Overview of Linfa sub-packages and algorithms

    master

    Linfa is a toolkit for building Machine Learning applications in Rust, similar in spirit to Python's scikit-learn. It provides various sub-packages categorized by learning type and purpose. Use the following list to identify the appropriate package for your machine learning task:

    Supervised Learning

    • bayes: Naive Bayes (Bernoulli, Gaussian, and Multinomial).
    • clustering: (Note: Often categorized as unsupervised, but used for labeling tasks).
    • ensemble: Bagging, Random Forest, and AdaBoost.
    • elasticnet: Linear regression with elastic net constraints.
    • lars: Least Angle Regression (LARS).
    • linear: Ordinary Least Squares (OLS) and Generalized Linear Models (GLM).
    • logistic: Two-class logistic regression.
    • pls: Partial Least Squares for dimensionality reduction and regression.
    • svm: Support Vector Machines for classification or regression.
    • trees: Linear decision trees.

    Unsupervised Learning

    • clustering: K-Means, Gaussian-Mixture-Model, DBSCAN, and OPTICS.
    • hierarchical: Agglomerative hierarchical clustering.
    • ica: Independent component analysis (FastICA).
    • tsne: Dimensionality reduction (exact solution and Barnes-Hut approximation).

    Pre-processing & Dimensionality Reduction

    • kernel: Kernel methods for mapping feature vectors into higher-dimensional space.
    • nn: Nearest Neighbours & Distances (spatial index structures and distance functions).
    • preprocessing: Data normalization/whitening and count vectorization/tf-idf.
    • reduction: Diffusion mapping, Principal Component Analysis (PCA), and Random projections.

    Partial Fit (Incremental Learning)

    • ftrl: Follow The Regularized Leader (L1 and L2 regularization) with possible incremental updates.
    • logistic: Logistic regression models.
  4. Overview of Linfa Machine Learning Toolkit

    master
    linfa is a comprehensive toolkit for building Machine Learning applications in Rust. It is inspired by Python's scikit-learn and focuses on common preprocessing tasks and classical machine learning algorithms. It is organized into several sub-packages covering supervised learning, unsupervised learning, and preprocessing.
  5. Use linfa-nn for Nearest Neighbor search

    master

    linfa-nn is a pure Rust implementation of nearest neighbor algorithms within the linfa machine learning ecosystem. It is used for proximity search: finding the point in a set that is closest or most similar to a query point based on a dissimilarity function.

    Currently, linfa-nn supports the following search implementations:

    • linear: A brute-force linear search.
    • balltree: A Ball Tree implementation for efficient spatial queries.
    • KDTree: A K-Dimensional Tree implementation for efficient spatial queries.
  6. Use decision tree learning with linfa-trees

    master
    The linfa-trees crate provides implementations for decision tree learning algorithms, which are non-parametric supervised learning methods used for both classification and regression. It is part of the linfa ecosystem, designed to provide a toolkit for classical Machine Learning in pure Rust.
  7. New algorithms available in Linfa 0.2.0

    master

    Linfa 0.2.0 introduced several new machine learning algorithms across various sub-crates. Depending on your use case, you can now access:

    • Linear Models: Ordinary Linear Regression and Generalized Linear Models (via linfa-linear).
    • Trees: Linear decision trees (via linfa-trees).
    • Dimensionality Reduction & ICA: Fast Independent Component Analysis (ICA), Principal Component Analysis (PCA), and Diffusion Maps (via linfa-ica and linfa-reduction).
    • Classification & SVM: Support Vector Machines (via linfa-svm) and Logistic Regression (via linfa-logistic).
    • Clustering: Hierarchical agglomerative clustering (via linfa-hierarchical) and Gaussian Mixture Models (via linfa-clustering).
  8. Use linfa-hierarchical for agglomerative clustering

    master
    The linfa-hierarchical crate provides an implementation of agglomerative hierarchical clustering. The algorithm starts by treating each data point as an individual cluster and iteratively merges pairs of clusters until a specified stopping criterion is met. Distances between points are calculated using the negative-log transform of a similarity kernel.
  9. Use Support Vector Machines with linfa-svm

    master

    The linfa-svm crate provides a pure Rust implementation of Support Vector Machines (SVM) for classification and regression tasks. It currently implements SVM using Sequential Minimal Optimization (SMO).

    Supported algorithms include:

    • Support Vector Classification: Supports C, Nu, and one-class formulations.
    • Support Vector Regression: Supports Epsilon and Nu formulations.