aprender-core 0.30.0

Next-generation machine learning library in pure Rust
docs.rs failed to build aprender-core-0.30.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

aprender-core

Crates.io docs.rs CI License: MIT

The core ML library for the Aprender framework — pure Rust, zero unsafe, 13,026 tests.

Published as aprender-core on crates.io; import as use aprender::*. Part of a 70-crate monorepo that ships the apr CLI (cargo install aprender).

Install

[dependencies]
aprender-core = "0.29"

# Optional features
aprender-core = { version = "0.29", features = ["format-compression", "format-quantize"] }

Or with cargo-add:

cargo add aprender-core

Quick Start

use aprender::linear_regression::LinearRegression;
use aprender::traits::Estimator;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Training data: y = 2x + 1
    let x = vec![vec![1.0], vec![2.0], vec![3.0], vec![4.0]];
    let y = vec![3.0, 5.0, 7.0, 9.0];

    let mut model = LinearRegression::new();
    model.fit(&x, &y)?;

    let predictions = model.predict(&vec![vec![5.0], vec![6.0]])?;
    println!("{predictions:?}"); // [11.0, 13.0]
    Ok(())
}
use aprender::kmeans::KMeans;
use aprender::traits::UnsupervisedEstimator;

let data = vec![
    vec![1.0, 2.0], vec![1.5, 1.8], vec![5.0, 8.0], vec![8.0, 8.0],
];
let mut model = KMeans::new(2, 100);
model.fit(&data)?;
let labels = model.predict(&data)?;

Features

Supervised Learning

  • Linear Regression, Logistic Regression
  • Decision Trees (CART), Random Forest, Gradient Boosting (GBM)
  • K-Nearest Neighbors (KNN), Support Vector Machines (SVM)

Unsupervised Learning

  • K-Means clustering, PCA decomposition, ICA

Time Series

  • ARIMA (AutoRegressive Integrated Moving Average)

Bayesian Inference

  • Conjugate priors, Bayesian Linear Regression
  • Generalized Linear Models (Poisson, Gamma, Binomial)

Graph Neural Networks

  • Dijkstra, A*, PageRank, community detection

Text Processing

  • BPE and SentencePiece tokenizers, stop words, stemming
  • Chat template engine (minijinja), chat markup language

APR Model Format

  • Read/write the native .apr binary format
  • format-compression feature: LZ4 and Zstd tensor compression
  • format-quantize feature: Q4K and Q6K quantization

Optional Feature Flags

Feature Description
format-compression LZ4 and Zstd compressed tensor storage
format-quantize Q4K / Q6K quantization for model export

Documentation

License

MIT. See LICENSE.