Skip to main content

anofox_ml/
lib.rs

1//! # anofox-ml
2//!
3//! A scikit-learn-style machine learning library for Rust.
4//!
5//! ## Quick Start
6//!
7//! ```rust
8//! use anofox_ml::prelude::*;
9//! use ndarray::array;
10//!
11//! // Fit a KNN classifier
12//! let x_train = array![[0.0, 0.0], [1.0, 1.0], [2.0, 2.0], [3.0, 3.0]];
13//! let y_train = array![0.0, 0.0, 1.0, 1.0];
14//!
15//! let knn = KnnClassifier { n_neighbors: 3, ..Default::default() };
16//! let model = knn.fit(&x_train, &y_train).unwrap();
17//!
18//! let x_test = array![[0.5, 0.5], [2.5, 2.5]];
19//! let predictions = model.predict(&x_test).unwrap();
20//! ```
21
22/// Core traits and types.
23pub mod core {
24    pub use anofox_ml_core::*;
25}
26
27/// Evaluation metrics.
28pub mod metrics {
29    pub use anofox_ml_metrics::*;
30}
31
32/// Feature preprocessing (scalers, PCA).
33pub mod preprocessing {
34    pub use anofox_ml_preprocessing::*;
35}
36
37/// K-nearest neighbors algorithms.
38pub mod neighbors {
39    pub use anofox_ml_neighbors::*;
40}
41
42/// Decision tree algorithms.
43pub mod trees {
44    pub use anofox_ml_trees::*;
45}
46
47/// Ensemble methods (Random Forest, Gradient Boosting, AdaBoost, ExtraTrees).
48pub mod ensemble {
49    pub use anofox_ml_ensemble::*;
50}
51
52/// Clustering algorithms (KMeans, DBSCAN).
53pub mod cluster {
54    pub use anofox_ml_cluster::*;
55}
56
57/// Naive Bayes classifiers.
58pub mod naive_bayes {
59    pub use anofox_ml_naive_bayes::*;
60}
61
62/// Linear and Quadratic Discriminant Analysis.
63pub mod discriminant {
64    pub use anofox_ml_discriminant::*;
65}
66
67/// Support Vector Machine classifiers.
68pub mod svm {
69    pub use anofox_ml_svm::*;
70}
71
72/// Neural network models (MLP).
73pub mod neural_networks {
74    pub use anofox_ml_neural_networks::*;
75}
76
77/// Classical regression models (OLS, Ridge, Elastic Net, GLM).
78pub mod regression {
79    pub use anofox_ml_regression::*;
80}
81
82/// SGD-based linear models (SGDClassifier, SGDRegressor).
83pub mod linear {
84    pub use anofox_ml_linear::*;
85}
86
87/// Data I/O utilities (CSV reading).
88pub mod io {
89    pub use anofox_ml_io::*;
90}
91
92/// Convenient prelude importing the most commonly used items.
93pub mod prelude {
94    pub use anofox_ml_core::{
95        cross_val_predict, cross_val_score, cross_val_score_stratified, cross_validate,
96        grid_search_cv, group_k_fold, k_fold, learning_curve, leave_one_out, leave_p_out,
97        randomized_search_cv, repeated_k_fold, repeated_stratified_k_fold, shuffle_split,
98        stratified_k_fold, stratified_shuffle_split, time_series_split, train_test_split,
99        validation_curve, ColumnSelector, ColumnTransformer, CrossValidateResult, FeatureUnion,
100        Fit, FitUnsupervised, FittedPipeline, Float, FunctionTransformer, GridSearchResult,
101        InverseTransform, Pipeline, Predict, Remainder, Transform,
102    };
103
104    pub use anofox_ml_metrics::{
105        accuracy_score, adjusted_rand_score, average_precision_score, balanced_accuracy_score,
106        brier_score_loss, cohen_kappa_score, confusion_matrix, explained_variance_score, f1_score,
107        f1_score_avg, log_loss, mae, matthews_corrcoef, max_error, mean_absolute_percentage_error,
108        mean_squared_log_error, median_absolute_error, mse, normalized_mutual_info_score,
109        precision, precision_recall_curve, precision_score, r2_score, recall, recall_score,
110        roc_auc_score, roc_curve, silhouette_score, Average,
111    };
112
113    pub use anofox_ml_preprocessing::{
114        BinStrategy, Binarizer, EncodeStrategy, ImputeStrategy, KBinsDiscretizer, KernelPca,
115        KpcaKernel, LabelEncoder, MaxAbsScaler, MinMaxScaler, MutualInformationSelector, Nmf,
116        NormType, Normalizer, OneHotEncoder, OrdinalEncoder, OutputDistribution, Pca,
117        PolynomialFeatures, PowerTransformer, QuantileTransformer, Rfe, RobustScaler,
118        SelectFromModel, SelectKBest, SequentialFeatureSelector, SimpleImputer, StandardScaler,
119        TruncatedSvd, VarianceThreshold,
120    };
121
122    pub use anofox_ml_neighbors::{
123        DistanceMetric, KnnClassifier, KnnRegressor, LocalOutlierFactor, WeightFunction,
124    };
125
126    pub use anofox_ml_trees::{
127        ClassWeight, DecisionTreeClassifier, DecisionTreeRegressor, MaxFeatures, SplitCriterion,
128    };
129
130    pub use anofox_ml_ensemble::{
131        AdaBoostClassifier, AdaBoostRegressor, BaggingClassifier, BaggingRegressor, BoostingType,
132        CalibratedClassifierCV, CalibrationMethod, ExtraTreesClassifier, ExtraTreesRegressor,
133        GradientBoostingClassifier, GradientBoostingRegressor, HistGradientBoostingClassifier,
134        HistGradientBoostingRegressor, IsolationForest, LgbmClassWeight, LgbmClassifier,
135        LgbmFitOptions, LgbmObjective, LgbmRegressor, RandomForestClassifier,
136        RandomForestRegressor, StackingClassifier, StackingRegressor, VotingClassifier,
137        VotingRegressor,
138    };
139
140    pub use anofox_ml_cluster::{
141        AgglomerativeClustering, CovarianceType, Dbscan, GaussianMixture, KMeans, Linkage,
142        MiniBatchKMeans,
143    };
144
145    pub use anofox_ml_naive_bayes::{BernoulliNB, GaussianNB, MultinomialNB};
146
147    pub use anofox_ml_discriminant::{
148        FittedLinearDiscriminantAnalysis, FittedQuadraticDiscriminantAnalysis,
149        LinearDiscriminantAnalysis, QuadraticDiscriminantAnalysis,
150    };
151
152    pub use anofox_ml_svm::{LinearSvc, LinearSvr, NuSvc, NuSvr, OneClassSvm, Svc, SvmKernel, Svr};
153
154    pub use anofox_ml_neural_networks::{MlpClassifier, MlpRegressor};
155
156    pub use anofox_ml_regression::{
157        ARDRegression, BayesianRidge, BinomialRegressor, ElasticNetCrossValidated,
158        ElasticNetRegressor, GammaRegressor, HuberRegressor, IsotonicRegressor, KernelRidge,
159        LassoCrossValidated, LassoRegressor, LogisticRegressor, OlsRegressor,
160        OrthogonalMatchingPursuit, PoissonRegressor, QuantileRegressor, RansacRegressor,
161        RidgeCrossValidated, RidgeRegressor, TheilSenRegressor, TransformedTargetRegressor,
162        TweedieRegressor, WlsRegressor,
163    };
164
165    pub use anofox_ml_linear::{
166        PassiveAggressiveClassifier, PassiveAggressiveRegressor, SgdClassifier, SgdRegressor,
167    };
168
169    pub use anofox_ml_text::{CountVectorizer, HashingVectorizer, TfidfVectorizer};
170
171    pub use anofox_ml_core::persistence::{load_bincode, load_json, save_bincode, save_json};
172}