Skip to main content

aprender/
lib.rs

1//! Aprender: Next-generation machine learning library in pure Rust.
2//!
3//! Aprender provides production-grade ML algorithms with a focus on
4//! ergonomic APIs, comprehensive testing, and backend-agnostic compute.
5//!
6//! # Quick Start
7//!
8//! ```
9//! use aprender::prelude::*;
10//!
11//! // Create training data (y = 2*x + 1)
12//! let x = Matrix::from_vec(4, 1, vec![
13//!     1.0,
14//!     2.0,
15//!     3.0,
16//!     4.0,
17//! ]).expect("valid matrix dimensions");
18//! let y = Vector::from_slice(&[3.0, 5.0, 7.0, 9.0]);
19//!
20//! // Train linear regression
21//! let mut model = LinearRegression::new();
22//! model.fit(&x, &y).expect("linear regression fit should succeed");
23//!
24//! // Make predictions
25//! let predictions = model.predict(&x);
26//! let r2 = model.score(&x, &y);
27//! assert!(r2 > 0.99);
28//! ```
29//!
30//! # Modules
31//!
32//! - [`primitives`]: Core Vector and Matrix types
33//! - [`data`]: `DataFrame` for named columns
34//! - [`linear_model`]: Linear regression algorithms
35//! - [`cluster`]: Clustering algorithms (K-Means)
36//! - [`code`]: Code analysis and code2vec embeddings
37//! - [`classification`]: Classification algorithms (Logistic Regression)
38//! - [`tree`]: Decision tree classifiers
39//! - [`metrics`]: Evaluation metrics
40//! - [`mining`]: Pattern mining algorithms (Apriori for association rules)
41//! - [`model_selection`]: Cross-validation and train/test splitting
42//! - [`preprocessing`]: Data transformers (scalers, encoders)
43//! - [`optim`]: Optimization algorithms (SGD, Adam)
44//! - [`loss`]: Loss functions for training (MSE, MAE, Huber)
45//! - [`serialization`]: Model serialization (`SafeTensors` format)
46//! - [`stats`]: Traditional descriptive statistics (quantiles, histograms)
47//! - [`graph`]: Graph construction and analysis (centrality, community detection)
48//! - [`bayesian`]: Bayesian inference (conjugate priors, MCMC, variational inference)
49//! - [`glm`]: Generalized Linear Models (Poisson, Gamma, Binomial families)
50//! - [`decomposition`]: Matrix decomposition (ICA, PCA)
51//! - [`text`]: Text processing and NLP (tokenization, stop words, stemming)
52//! - [`time_series`]: Time series analysis and forecasting (ARIMA)
53//! - [`index`]: Approximate nearest neighbor search (HNSW)
54//! - [`recommend`]: Recommendation systems (content-based, collaborative filtering)
55//! - [`synthetic`]: Synthetic data generation for `AutoML` (EDA, back-translation, `MixUp`)
56//! - [`bundle`]: Model bundling and memory paging for large models
57//! - [`cache`]: Cache hierarchy and model registry for large model management
58//! - [`chaos`]: Chaos engineering configuration (from renacer)
59//! - [`inspect`]: Model inspection tooling (header analysis, diff, quality scoring)
60//! - [`loading`]: Model loading subsystem with WCET and cryptographic agility
61//! - [`scoring`]: 100-point model quality scoring system
62//! - [`zoo`]: Model zoo protocol for sharing and discovery
63//! - [`embed`]: Data embedding with test data and tiny model representations
64//! - [`native`]: SIMD-native model format for zero-copy inference
65//! - [`stack`]: Sovereign AI Stack integration types
66//! - [`online`]: Online learning and dynamic retraining infrastructure
67
68// GH-41: unwrap() banned in production code via .clippy.toml.
69// Tests use unwrap() freely — scoped allow for test builds only.
70#![cfg_attr(test, allow(clippy::disallowed_methods))]
71
72pub mod active_learning;
73/// Audio I/O and signal processing (mel spectrogram, resampling, capture)
74#[cfg(feature = "audio")]
75pub mod audio;
76pub mod autograd;
77pub mod automl;
78pub mod bayesian;
79/// Model evaluation and benchmarking framework (spec §7.10)
80pub mod bench;
81/// Benchmark visualization with rich colors and scientific statistics (PAR-040)
82///
83/// Creates 2×3 grid visualizations for inference comparisons with:
84/// - ANSI terminal colors for clear pass/fail/warn status
85/// - Multi-iteration statistics (mean, std dev, 95% CI)
86/// - Criterion-style scientific benchmarking output
87/// - Chat-pasteable profiling logs for debugging
88pub mod bench_viz;
89pub mod bundle;
90pub mod cache;
91pub mod calibration;
92pub mod chaos;
93/// Compiler-in-the-Loop Learning (CITL) for transpiler support.
94pub mod citl;
95pub mod classification;
96pub mod cluster;
97pub mod code;
98/// Compute infrastructure integration (trueno 0.8.7+)
99pub mod compute;
100pub mod data;
101pub mod decomposition;
102/// End-to-end demo infrastructure for Qwen2-0.5B WASM demo (spec §J)
103pub mod demo;
104/// Data embedding with test data and tiny model representations (spec §4)
105pub mod embed;
106pub mod ensemble;
107pub mod error;
108/// Explainability wrappers for inference monitoring
109pub mod explainable;
110pub mod format;
111pub mod glm;
112pub mod gnn;
113pub mod graph;
114/// Hugging Face Hub integration (GH-100)
115#[cfg(feature = "hf-hub-integration")]
116pub mod hf_hub;
117pub mod index;
118/// Model inspection tooling (spec §7.2)
119pub mod inspect;
120pub mod interpret;
121pub mod linear_model;
122/// Model loading subsystem with WCET and cryptographic agility (spec §7.1)
123pub mod loading;
124/// TensorLogic: Neuro-symbolic reasoning via tensor operations (Domingos, 2025)
125pub mod logic;
126pub mod loss;
127pub mod metaheuristics;
128pub mod metrics;
129pub mod mining;
130pub mod model_selection;
131/// Pre-trained model architectures (Qwen2, etc.)
132pub mod models;
133pub mod monte_carlo;
134/// SIMD-native model format for zero-copy Trueno inference (spec §5)
135pub mod native;
136pub mod nn;
137/// Online learning and dynamic retraining infrastructure
138pub mod online;
139pub mod optim;
140pub mod prelude;
141pub mod preprocessing;
142pub mod primitives;
143/// Neural network pruning: importance scoring, sparsity masks, and compression.
144pub mod pruning;
145/// Model Quality Assurance module (spec §7.9)
146pub mod qa;
147pub mod recommend;
148pub mod regularization;
149/// 100-point model quality scoring system (spec §7)
150pub mod scoring;
151pub mod serialization;
152/// GPU Inference Showcase with PMAT verification (PAR-040)
153///
154/// Benchmark harness for Qwen2.5-Coder showcase demonstrating >2x performance:
155/// - trueno GPU PTX generation (persistent kernels, megakernels)
156/// - trueno SIMD (AVX2/AVX-512/NEON)
157/// - trueno-zram KV cache compression
158/// - renacer GPU kernel profiling
159pub mod showcase;
160/// Speech processing: VAD, ASR, TTS, diarization (spec §5, GH-133)
161pub mod speech;
162/// Sovereign AI Stack integration types (spec §9)
163pub mod stack;
164pub mod stats;
165pub mod synthetic;
166pub mod text;
167pub mod time_series;
168pub mod traits;
169pub mod transfer;
170pub mod tree;
171/// Pipeline verification & visualization system (APR-VERIFY-001)
172pub mod verify;
173/// Voice processing: embeddings, style transfer, cloning (GH-132)
174pub mod voice;
175/// WASM/SIMD integration for browser-based inference (spec §L)
176pub mod wasm;
177pub mod weak_supervision;
178/// Model zoo protocol for sharing and discovery (spec §8)
179pub mod zoo;
180
181pub use error::{AprenderError, Result};
182pub use primitives::{Matrix, Vector};
183pub use traits::{Estimator, Transformer, UnsupervisedEstimator};