ghostflow_ml/lib.rs
1//! GhostFlow Classical ML Algorithms
2//!
3//! Comprehensive real implementations of classical machine learning algorithms.
4//! No mocks, no simulations - production-ready ML from scratch.
5//!
6//! ## Modules
7//! - **tree**: Decision Trees (CART)
8//! - **ensemble**: Random Forest, Gradient Boosting
9//! - **ensemble_advanced**: AdaBoost, Bagging, Extra Trees, Isolation Forest
10//! - **stacking**: Stacking Classifier/Regressor
11//! - **linear**: Linear/Logistic Regression, Ridge, Lasso, ElasticNet
12//! - **robust**: Huber, RANSAC, Theil-Sen, Quantile Regression
13//! - **svm**: Support Vector Machines (SVC, SVR)
14//! - **kernel**: Kernel Ridge, Kernel PCA, Nystrom
15//! - **neighbors**: K-Nearest Neighbors
16//! - **naive_bayes**: Gaussian, Multinomial, Bernoulli NB
17//! - **bayesian**: Bayesian Ridge, ARD Regression
18//! - **discriminant_analysis**: LDA, QDA
19//! - **gaussian_process**: GP Regressor, GP Classifier
20//! - **mixture**: Gaussian Mixture, Bayesian GMM
21//! - **neural_network**: Perceptron, MLP
22//! - **rbf_network**: RBF Network, RBF Classifier
23//! - **clustering**: KMeans, DBSCAN, Agglomerative
24//! - **clustering_advanced**: Spectral, Mean Shift, Mini-Batch KMeans, Affinity Propagation
25//! - **clustering_more**: OPTICS, BIRCH, HDBSCAN
26//! - **decomposition**: PCA, SVD, NMF
27//! - **decomposition_advanced**: Factor Analysis, ICA, Sparse PCA, Dictionary Learning
28//! - **manifold**: t-SNE, MDS, Isomap, LLE
29//! - **outlier_detection**: LOF, One-Class SVM, Elliptic Envelope
30//! - **feature_selection**: Variance Threshold, SelectKBest, RFE
31//! - **metrics**: Classification, Regression, Clustering metrics
32//! - **metrics_advanced**: Log Loss, Hinge Loss, Cohen's Kappa, Matthews Correlation
33//! - **preprocessing**: Scalers, Encoders
34//! - **polynomial**: Polynomial Features, Spline Transformer, Power Transformer
35//! - **model_selection**: Cross-validation, Grid Search
36//! - **calibration**: Isotonic Regression, Platt Scaling, Calibrated Classifier
37//! - **semi_supervised**: Label Propagation, Label Spreading, Self-Training
38//! - **multiclass**: One-vs-Rest, One-vs-One, Output Code, Classifier Chain
39//! - **imbalanced**: SMOTE, Random Over/Under Sampling
40//! - **time_series**: ARIMA, Exponential Smoothing
41//! - **time_series_extended**: SARIMA, STL Decomposition
42//! - **linear_sgd**: SGD Classifier/Regressor
43//! - **decomposition_incremental**: Incremental PCA
44//! - **preprocessing_extended**: RobustScaler, MaxAbsScaler, OrdinalEncoder
45//! - **model_selection_extended**: RandomizedSearchCV, GroupKFold, Learning Curves
46//! - **nlp**: Tokenizers, Word2Vec, TF-IDF
47//! - **vision**: Image Augmentation, Normalization, Resizing
48//! - **distributed**: Data Parallelism, Gradient Compression, Ring All-Reduce
49//! - **gpu**: GPU Acceleration, CUDA Support, Mixed Precision
50//! - **deep**: Deep Learning (CNN, RNN, LSTM, GRU, Transformer, Optimizers, Losses)
51
52// Core modules
53pub mod tree;
54pub mod ensemble;
55pub mod ensemble_advanced;
56pub mod stacking;
57pub mod linear;
58pub mod robust;
59pub mod clustering;
60pub mod clustering_advanced;
61pub mod clustering_more;
62pub mod decomposition;
63pub mod decomposition_advanced;
64pub mod neighbors;
65pub mod svm;
66pub mod kernel;
67
68// Probabilistic models
69pub mod naive_bayes;
70pub mod bayesian;
71pub mod discriminant_analysis;
72pub mod gaussian_process;
73pub mod mixture;
74
75// Neural Networks
76pub mod neural_network;
77pub mod rbf_network;
78
79// Dimensionality reduction & manifold learning
80pub mod manifold;
81
82// Outlier Detection
83pub mod outlier_detection;
84
85// Feature Selection
86pub mod feature_selection;
87
88// Utilities
89pub mod metrics;
90pub mod metrics_advanced;
91pub mod preprocessing;
92pub mod polynomial;
93pub mod model_selection;
94
95// Semi-supervised & Calibration
96pub mod calibration;
97pub mod semi_supervised;
98
99// Multiclass strategies
100pub mod multiclass;
101
102// Imbalanced Learning
103pub mod imbalanced;
104
105// Time Series
106pub mod time_series;
107pub mod time_series_extended;
108
109// Extended modules
110pub mod linear_sgd;
111pub mod decomposition_incremental;
112pub mod preprocessing_extended;
113pub mod model_selection_extended;
114
115// NLP & Vision
116pub mod nlp;
117pub mod vision;
118
119// Distributed & GPU
120pub mod distributed;
121pub mod gpu;
122
123// Deep Learning
124// NOTE: Deep module has compilation issues - disabled for now
125// pub mod deep;
126
127// Re-exports: Trees
128pub use tree::{DecisionTreeClassifier, DecisionTreeRegressor, Criterion};
129
130// Re-exports: Ensemble methods
131pub use ensemble::{
132 RandomForestClassifier, RandomForestRegressor,
133 GradientBoostingClassifier, GradientBoostingRegressor,
134};
135pub use ensemble_advanced::{
136 AdaBoostClassifier, BaggingClassifier, ExtraTreesClassifier,
137 VotingClassifier, IsolationForest,
138};
139pub use stacking::{StackingClassifier, StackingRegressor, StackMethod};
140
141// Re-exports: Linear models
142pub use linear::{LinearRegression, LogisticRegression, Ridge, Lasso, ElasticNet};
143pub use robust::{HuberRegressor, RANSACRegressor, TheilSenRegressor, QuantileRegressor, PassiveAggressiveRegressor};
144
145// Re-exports: Clustering
146pub use clustering::{KMeans, DBSCAN, AgglomerativeClustering};
147pub use clustering_advanced::{
148 SpectralClustering, MeanShift, MiniBatchKMeans, AffinityPropagation,
149};
150pub use clustering_more::{OPTICS, BIRCH, HDBSCAN};
151
152// Re-exports: Mixture Models
153pub use mixture::{GaussianMixture, BayesianGaussianMixture, CovarianceType};
154
155// Re-exports: Decomposition
156pub use decomposition::{PCA, SVD, NMF};
157pub use decomposition_advanced::{FactorAnalysis, FastICA, SparsePCA, DictionaryLearning};
158
159// Re-exports: Neighbors
160pub use neighbors::{KNeighborsClassifier, KNeighborsRegressor};
161
162// Re-exports: SVM
163pub use svm::{SVC, SVR, Kernel as SVMKernel};
164
165// Re-exports: Kernel Methods
166pub use kernel::{KernelRidge, KernelPCA, Nystrom, Kernel};
167
168// Re-exports: Naive Bayes
169pub use naive_bayes::{GaussianNB, MultinomialNB, BernoulliNB, ComplementNB};
170
171// Re-exports: Bayesian
172pub use bayesian::{BayesianRidge, ARDRegression};
173
174// Re-exports: Discriminant Analysis
175pub use discriminant_analysis::{LinearDiscriminantAnalysis, QuadraticDiscriminantAnalysis};
176
177// Re-exports: Gaussian Processes
178pub use gaussian_process::{GaussianProcessRegressor, GaussianProcessClassifier, GPKernel};
179
180// Re-exports: Neural Networks
181pub use neural_network::{Perceptron, MLPClassifier, MLPRegressor, Activation};
182pub use rbf_network::{RBFNetwork, RBFClassifier};
183
184// Re-exports: Manifold Learning
185pub use manifold::{TSNE, MDS, Isomap, LocallyLinearEmbedding};
186
187// Re-exports: Outlier Detection
188pub use outlier_detection::{LocalOutlierFactor, OneClassSVM, EllipticEnvelope};
189
190// Re-exports: Feature Selection
191pub use feature_selection::{VarianceThreshold, SelectKBest, RFE, ScoreFunction};
192
193// Re-exports: Preprocessing
194pub use preprocessing::{
195 StandardScaler, MinMaxScaler, Normalizer,
196 LabelEncoder, OneHotEncoder, train_test_split,
197};
198pub use polynomial::{
199 PolynomialFeatures, SplineTransformer, PowerTransformer, QuantileTransformer,
200 PowerMethod, OutputDistribution,
201};
202
203// Re-exports: Multiclass
204pub use multiclass::{OneVsRestClassifier, OneVsOneClassifier, OutputCodeClassifier, ClassifierChain};
205
206// Re-exports: Metrics
207pub use metrics::{
208 // Classification
209 accuracy_score, precision_score, recall_score, f1_score,
210 confusion_matrix, roc_auc_score, classification_report,
211 // Regression
212 mean_squared_error, root_mean_squared_error, mean_absolute_error,
213 r2_score, mean_absolute_percentage_error, explained_variance_score,
214 // Clustering
215 silhouette_score, davies_bouldin_score,
216};
217pub use metrics_advanced::{
218 log_loss, log_loss_multiclass, hinge_loss, squared_hinge_loss,
219 cohen_kappa_score, matthews_corrcoef, adjusted_rand_score,
220 normalized_mutual_info_score, fowlkes_mallows_score,
221 calinski_harabasz_score,
222};
223
224// Re-exports: Model Selection
225pub use model_selection::{
226 KFold, StratifiedKFold, LeaveOneOut, TimeSeriesSplit,
227 cross_val_score, parameter_grid, shuffle_split,
228};
229
230// Re-exports: Calibration
231pub use calibration::{IsotonicRegression, PlattScaling, CalibratedClassifier};
232
233// Re-exports: Semi-supervised
234pub use semi_supervised::{LabelPropagation, LabelSpreading, SelfTrainingClassifier};
235
236// Re-exports: Imbalanced Learning
237pub use imbalanced::{RandomOverSampler, RandomUnderSampler, SMOTE, BorderlineSMOTE, ADASYN, SamplingStrategy};
238
239// Re-exports: Time Series
240pub use time_series::{
241 SimpleExponentialSmoothing, HoltLinear, HoltWinters, SeasonalType,
242 ARIMA, MovingAverage, EWMA,
243};
244pub use time_series_extended::SARIMA;
245
246// Re-exports: Extended Linear Models
247pub use linear_sgd::{SGDClassifier, SGDRegressor, SGDLoss, SGDRegressorLoss, Penalty, LearningRate};
248
249// Re-exports: Extended Decomposition
250pub use decomposition_incremental::IncrementalPCA;
251
252// Re-exports: Extended Preprocessing
253pub use preprocessing_extended::{RobustScaler, MaxAbsScaler, OrdinalEncoder};
254
255// Re-exports: Extended Model Selection
256pub use model_selection_extended::{
257 RandomizedSearchCV, ParamDistribution, RandomizedSearchResult, CVResult,
258 GroupKFold, RepeatedKFold, StratifiedShuffleSplit, Scoring,
259 learning_curve, validation_curve,
260};
261
262// Re-exports: Deep Learning
263// NOTE: Deep module disabled - has compilation issues
264/*
265pub use deep::{
266 // Layers
267 Dense, Dropout, BatchNorm, LayerNorm, Embedding, Flatten,
268 // CNN
269 Conv2d, Conv1d, Conv3d, MaxPool2d, AvgPool2d, GlobalAvgPool2d,
270 BatchNorm2d, GroupNorm,
271 // RNN
272 RNNCell, LSTMCell, GRUCell, RNN, LSTM, GRU,
273 // Transformer
274 ScaledDotProductAttention, MultiHeadAttention, PositionalEncoding,
275 FeedForward, TransformerLayerNorm, TransformerEncoderLayer, TransformerEncoder,
276 TransformerDecoderLayer, TransformerDecoder, Transformer,
277 PatchEmbedding, VisionTransformer,
278 // Optimizers
279 SGD, Adam, AdamW, RMSprop, AdaGrad, Adadelta, Adamax, NAdam, RAdam,
280 // Losses
281 MSELoss, CrossEntropyLoss, BCELoss, BCEWithLogitsLoss, HuberLoss as DeepHuberLoss,
282 L1Loss, HingeLoss as DeepHingeLoss, KLDivLoss, Reduction,
283 FocalLoss, DiceLoss, TverskyLoss, LovaszLoss, ContrastiveLoss, TripletLoss,
284 CenterLoss, LabelSmoothingLoss,
285 // Activations
286 ReLU, LeakyReLU, PReLU, ELU, SELU, Sigmoid, Tanh, Softmax, GELU, Swish, Mish, Hardswish,
287};
288*/
289
290// Re-exports: NLP
291pub use nlp::{
292 WordTokenizer, CharTokenizer, BPETokenizer,
293 TfidfVectorizer, Word2Vec,
294};
295
296// Re-exports: Vision
297pub use vision::{
298 ImageAugmentation, ImageNormalization, ImageResize, ImageCrop,
299 RandomCrop, ColorJitter, Interpolation,
300};
301
302// Re-exports: Distributed Training
303pub use distributed::{
304 DistributedStrategy, CommunicationBackend, GradientAggregation,
305 DistributedConfig, DataParallelTrainer, DistributedDataLoader,
306 GradientCompression, CompressionMethod, RingAllReduce,
307};
308
309// Re-exports: GPU Acceleration
310pub use gpu::{
311 DeviceType, DeviceInfo, GPUContext, GPUTensor, GPUOps,
312 GPUMemoryManager, AutoMixedPrecision,
313};