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//! ]).unwrap();
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).unwrap();
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
68pub mod active_learning;
69/// Audio I/O and signal processing (mel spectrogram, resampling, capture)
70#[cfg(feature = "audio")]
71pub mod audio;
72pub mod autograd;
73pub mod automl;
74pub mod bayesian;
75/// Model evaluation and benchmarking framework (spec §7.10)
76pub mod bench;
77pub mod bundle;
78pub mod cache;
79pub mod calibration;
80pub mod chaos;
81/// Compiler-in-the-Loop Learning (CITL) for transpiler support.
82pub mod citl;
83pub mod classification;
84pub mod cluster;
85pub mod code;
86/// Compute infrastructure integration (trueno 0.8.7+)
87pub mod compute;
88pub mod data;
89pub mod decomposition;
90/// End-to-end demo infrastructure for Qwen2-0.5B WASM demo (spec §J)
91pub mod demo;
92/// Data embedding with test data and tiny model representations (spec §4)
93pub mod embed;
94pub mod ensemble;
95pub mod error;
96/// Explainability wrappers for inference monitoring (entrenar integration)
97#[cfg(feature = "inference-monitoring")]
98pub mod explainable;
99pub mod format;
100pub mod glm;
101pub mod gnn;
102pub mod graph;
103/// Hugging Face Hub integration (GH-100)
104#[cfg(feature = "hf-hub-integration")]
105pub mod hf_hub;
106pub mod index;
107/// Model inspection tooling (spec §7.2)
108pub mod inspect;
109pub mod interpret;
110pub mod linear_model;
111/// Model loading subsystem with WCET and cryptographic agility (spec §7.1)
112pub mod loading;
113/// TensorLogic: Neuro-symbolic reasoning via tensor operations (Domingos, 2025)
114pub mod logic;
115pub mod loss;
116pub mod metaheuristics;
117pub mod metrics;
118pub mod mining;
119pub mod model_selection;
120/// Pre-trained model architectures (Qwen2, etc.)
121pub mod models;
122pub mod monte_carlo;
123/// SIMD-native model format for zero-copy Trueno inference (spec §5)
124pub mod native;
125pub mod nn;
126/// Online learning and dynamic retraining infrastructure
127pub mod online;
128pub mod optim;
129pub mod prelude;
130pub mod preprocessing;
131pub mod primitives;
132/// Model Quality Assurance module (spec §7.9)
133pub mod qa;
134pub mod recommend;
135pub mod regularization;
136/// 100-point model quality scoring system (spec §7)
137pub mod scoring;
138pub mod serialization;
139/// Speech processing: VAD, ASR, TTS, diarization (spec §5, GH-133)
140pub mod speech;
141/// Sovereign AI Stack integration types (spec §9)
142pub mod stack;
143pub mod stats;
144pub mod synthetic;
145pub mod text;
146pub mod time_series;
147pub mod traits;
148pub mod transfer;
149pub mod tree;
150/// Pipeline verification & visualization system (APR-VERIFY-001)
151pub mod verify;
152/// Voice processing: embeddings, style transfer, cloning (GH-132)
153pub mod voice;
154/// WASM/SIMD integration for browser-based inference (spec §L)
155pub mod wasm;
156pub mod weak_supervision;
157/// Model zoo protocol for sharing and discovery (spec §8)
158pub mod zoo;
159
160pub use error::{AprenderError, Result};
161pub use primitives::{Matrix, Vector};
162pub use traits::{Estimator, Transformer, UnsupervisedEstimator};