Skip to main content

ferrolearn_linear/
lib.rs

1//! # ferrolearn-linear
2//!
3//! Linear models for the ferrolearn machine learning framework.
4//!
5//! This crate provides implementations of the most common linear models
6//! for both regression and classification tasks:
7//!
8//! - **[`LinearRegression`]** — Ordinary Least Squares via QR decomposition
9//! - **[`Ridge`]** — L2-regularized regression via Cholesky decomposition
10//! - **[`Lasso`]** — L1-regularized regression via coordinate descent
11//! - **[`ElasticNet`]** — Combined L1/L2 regularization via coordinate descent
12//! - **[`BayesianRidge`]** — Bayesian Ridge with automatic regularization tuning
13//! - **[`HuberRegressor`]** — Robust regression via IRLS with Huber loss
14//! - **[`LogisticRegression`]** — Binary and multiclass classification via L-BFGS
15//!
16//! All models implement the [`ferrolearn_core::Fit`] and [`ferrolearn_core::Predict`]
17//! traits, and produce fitted types that implement [`ferrolearn_core::introspection::HasCoefficients`].
18//!
19//! # Design
20//!
21//! Each model follows the compile-time safety pattern:
22//!
23//! - The unfitted struct (e.g., `LinearRegression<F>`) holds hyperparameters
24//!   and implements [`Fit`](ferrolearn_core::Fit).
25//! - Calling `fit()` produces a new fitted type (e.g., `FittedLinearRegression<F>`)
26//!   that implements [`Predict`](ferrolearn_core::Predict).
27//! - Calling `predict()` on an unfitted model is a compile-time error.
28//!
29//! # Pipeline Integration
30//!
31//! All models implement [`PipelineEstimator`](ferrolearn_core::pipeline::PipelineEstimator)
32//! for `f64`, allowing them to be used as the final step in a
33//! [`Pipeline`](ferrolearn_core::pipeline::Pipeline).
34//!
35//! # Float Generics
36//!
37//! All models are generic over `F: num_traits::Float + Send + Sync + 'static`,
38//! supporting both `f32` and `f64`.
39
40pub mod bayesian_ridge;
41pub mod elastic_net;
42pub mod huber_regressor;
43pub mod isotonic;
44pub mod lasso;
45pub mod lda;
46mod linalg;
47pub mod linear_regression;
48pub mod logistic_regression;
49mod optim;
50pub mod ransac;
51pub mod ridge;
52pub mod sgd;
53pub mod svm;
54
55// Re-export the main types at the crate root.
56pub use bayesian_ridge::{BayesianRidge, FittedBayesianRidge};
57pub use elastic_net::{ElasticNet, FittedElasticNet};
58pub use huber_regressor::{FittedHuberRegressor, HuberRegressor};
59pub use isotonic::{FittedIsotonicRegression, IsotonicRegression};
60pub use lasso::{FittedLasso, Lasso};
61pub use lda::{FittedLDA, LDA};
62pub use linear_regression::{FittedLinearRegression, LinearRegression};
63pub use logistic_regression::{FittedLogisticRegression, LogisticRegression};
64pub use ransac::{FittedRANSACRegressor, RANSACRegressor};
65pub use ridge::{FittedRidge, Ridge};
66pub use sgd::{FittedSGDClassifier, FittedSGDRegressor, SGDClassifier, SGDRegressor};
67pub use svm::{
68    FittedSVC, FittedSVR, Kernel, LinearKernel, PolynomialKernel, RbfKernel, SVC, SVR,
69    SigmoidKernel,
70};