Aprender provides implementations of classical machine learning algorithms optimized for performance and safety. The library requires no external dependencies beyond the Rust standard library and offers seamless compilation to WebAssembly.
Table of Contents
Features
- Pure Rust — Zero C/C++ dependencies, memory-safe, thread-safe by default
- SIMD Acceleration — Vectorized operations via trueno backend
- WebAssembly Ready — Compile to WASM for browser and edge deployment
- Native Model Format —
.aprformat with encryption, signatures, and zero-copy loading - Interoperability — Export to SafeTensors and GGUF formats
Installation
Add aprender to your Cargo.toml:
[]
= "0.11"
Optional Features
[]
= { = "0.11", = ["format-encryption", "hf-hub-integration"] }
| Feature | Description |
|---|---|
format-encryption |
AES-256-GCM encryption for model files |
format-signing |
Ed25519 digital signatures |
format-compression |
Zstd compression |
hf-hub-integration |
Hugging Face Hub push/pull support |
gpu |
GPU acceleration via wgpu |
Quick Start
use *;
Algorithms
Supervised Learning
| Algorithm | Description |
|---|---|
LinearRegression |
Ordinary least squares regression |
LogisticRegression |
Binary and multiclass classification |
DecisionTreeClassifier |
GINI-based decision trees |
RandomForestClassifier |
Bootstrap aggregating ensemble |
GradientBoostingClassifier |
Adaptive boosting with residual learning |
NaiveBayes |
Gaussian naive Bayes classifier |
KNeighborsClassifier |
k-nearest neighbors |
LinearSVM |
Support vector machine with hinge loss |
Unsupervised Learning
| Algorithm | Description |
|---|---|
KMeans |
k-means++ initialization with Lloyd's algorithm |
DBSCAN |
Density-based spatial clustering |
PCA |
Principal component analysis |
IsolationForest |
Anomaly detection |
Additional Modules
- Graph Analysis — PageRank, betweenness centrality, community detection
- Time Series — ARIMA forecasting
- Text Processing — Tokenization, TF-IDF, stemming
- Neural Networks — Sequential models, transformers, mixture of experts
Model Persistence
The .apr format provides secure, efficient model serialization:
use ;
// Save with encryption
save?;
// Load
let model: LinearRegression = load?;
Format Capabilities
- Security — AES-256-GCM encryption, Ed25519 signatures, X25519 key exchange
- Performance — Memory-mapped loading, 600x faster than standard deserialization
- Integrity — CRC32 checksums with automatic corruption detection
- Commercial — License blocks, watermarking, buyer-specific encryption
Documentation
| Resource | Link |
|---|---|
| API Reference | docs.rs/aprender |
| User Guide | paiml.github.io/aprender |
| Examples | examples/ |
| Model Format Spec | docs/specifications/model-format-spec.md |
Contributing
We welcome contributions. Please ensure your changes pass the test suite:
See CONTRIBUTING.md for guidelines.
License
Aprender is distributed under the MIT License. See LICENSE for details.