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//! - **[`RidgeCV`]** — Ridge with built-in cross-validated alpha selection
11//! - **[`Lasso`]** — L1-regularized regression via coordinate descent
12//! - **[`LassoCV`]** — Lasso with built-in cross-validated alpha selection
13//! - **[`ElasticNet`]** — Combined L1/L2 regularization via coordinate descent
14//! - **[`ElasticNetCV`]** — ElasticNet with cross-validated (alpha, l1_ratio) selection
15//! - **[`BayesianRidge`]** — Bayesian Ridge with automatic regularization tuning
16//! - **[`HuberRegressor`]** — Robust regression via IRLS with Huber loss
17//! - **[`LogisticRegression`]** — Binary and multiclass classification via L-BFGS
18//!
19//! All models implement the [`ferrolearn_core::Fit`] and [`ferrolearn_core::Predict`]
20//! traits, and produce fitted types that implement [`ferrolearn_core::introspection::HasCoefficients`].
21//!
22//! # Design
23//!
24//! Each model follows the compile-time safety pattern:
25//!
26//! - The unfitted struct (e.g., `LinearRegression<F>`) holds hyperparameters
27//! and implements [`Fit`](ferrolearn_core::Fit).
28//! - Calling `fit()` produces a new fitted type (e.g., `FittedLinearRegression<F>`)
29//! that implements [`Predict`](ferrolearn_core::Predict).
30//! - Calling `predict()` on an unfitted model is a compile-time error.
31//!
32//! # Pipeline Integration
33//!
34//! All models implement [`PipelineEstimator`](ferrolearn_core::pipeline::PipelineEstimator)
35//! for `f64`, allowing them to be used as the final step in a
36//! [`Pipeline`](ferrolearn_core::pipeline::Pipeline).
37//!
38//! # Float Generics
39//!
40//! All models are generic over `F: num_traits::Float + Send + Sync + 'static`,
41//! supporting both `f32` and `f64`.
42
43pub mod bayesian_ridge;
44pub mod elastic_net;
45pub mod elastic_net_cv;
46pub mod huber_regressor;
47pub mod isotonic;
48pub mod lasso;
49pub mod lasso_cv;
50pub mod lda;
51mod linalg;
52pub mod linear_regression;
53pub mod logistic_regression;
54pub mod nu_svm;
55pub mod one_class_svm;
56mod optim;
57pub mod ransac;
58pub mod ridge;
59pub mod ridge_cv;
60pub mod sgd;
61pub mod svm;
62
63// Re-export the main types at the crate root.
64pub use bayesian_ridge::{BayesianRidge, FittedBayesianRidge};
65pub use elastic_net::{ElasticNet, FittedElasticNet};
66pub use elastic_net_cv::{ElasticNetCV, FittedElasticNetCV};
67pub use huber_regressor::{FittedHuberRegressor, HuberRegressor};
68pub use isotonic::{FittedIsotonicRegression, IsotonicRegression};
69pub use lasso::{FittedLasso, Lasso};
70pub use lasso_cv::{FittedLassoCV, LassoCV};
71pub use lda::{FittedLDA, LDA};
72pub use linear_regression::{FittedLinearRegression, LinearRegression};
73pub use logistic_regression::{FittedLogisticRegression, LogisticRegression};
74pub use nu_svm::{FittedNuSVC, FittedNuSVR, NuSVC, NuSVR};
75pub use one_class_svm::{FittedOneClassSVM, OneClassSVM};
76pub use ransac::{FittedRANSACRegressor, RANSACRegressor};
77pub use ridge::{FittedRidge, Ridge};
78pub use ridge_cv::{FittedRidgeCV, RidgeCV};
79pub use sgd::{FittedSGDClassifier, FittedSGDRegressor, SGDClassifier, SGDRegressor};
80pub use svm::{
81 FittedSVC, FittedSVR, Kernel, LinearKernel, PolynomialKernel, RbfKernel, SVC, SVR,
82 SigmoidKernel,
83};