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;
74pub mod gmm;  // Gaussian Mixture Models (v0.3.0)
75pub mod hmm;  // Hidden Markov Models (v0.3.0)
76
77// Advanced Gradient Boosting (v0.3.0)
78pub mod gradient_boosting;  // XGBoost-style
79pub mod lightgbm;           // LightGBM-style
80pub mod crf;                // Conditional Random Fields
81pub mod feature_engineering;  // Feature engineering utilities
82pub mod hyperparameter_optimization;  // Bayesian optimization, etc.
83
84// Neural Networks
85pub mod neural_network;
86pub mod rbf_network;
87
88// Dimensionality reduction & manifold learning
89pub mod manifold;
90
91// Outlier Detection
92pub mod outlier_detection;
93
94// Feature Selection
95pub mod feature_selection;
96
97// Utilities
98pub mod metrics;
99pub mod metrics_advanced;
100pub mod preprocessing;
101pub mod polynomial;
102pub mod model_selection;
103
104// Semi-supervised & Calibration
105pub mod calibration;
106pub mod semi_supervised;
107
108// Multiclass strategies
109pub mod multiclass;
110
111// Imbalanced Learning
112pub mod imbalanced;
113
114// Time Series
115pub mod time_series;
116pub mod time_series_extended;
117
118// Extended modules
119pub mod linear_sgd;
120pub mod decomposition_incremental;
121pub mod preprocessing_extended;
122pub mod model_selection_extended;
123
124// NLP & Vision
125pub mod nlp;
126pub mod vision;
127
128// Distributed & GPU
129pub mod distributed;
130pub mod gpu;
131
132// Deep Learning
133// NOTE: Deep module has compilation issues - disabled for now
134// pub mod deep;
135
136// Neural Architecture Search
137pub mod nas;
138
139// AutoML
140pub mod automl;
141
142// Re-exports: Trees
143pub use tree::{DecisionTreeClassifier, DecisionTreeRegressor, Criterion};
144
145// Re-exports: Ensemble methods
146pub use ensemble::{
147    RandomForestClassifier, RandomForestRegressor,
148    GradientBoostingClassifier, GradientBoostingRegressor,
149};
150pub use ensemble_advanced::{
151    AdaBoostClassifier, BaggingClassifier, ExtraTreesClassifier,
152    VotingClassifier, IsolationForest,
153};
154pub use stacking::{StackingClassifier, StackingRegressor, StackMethod};
155
156// Re-exports: Linear models
157pub use linear::{LinearRegression, LogisticRegression, Ridge, Lasso, ElasticNet};
158pub use robust::{HuberRegressor, RANSACRegressor, TheilSenRegressor, QuantileRegressor, PassiveAggressiveRegressor};
159
160// Re-exports: Clustering
161pub use clustering::{KMeans, DBSCAN, AgglomerativeClustering};
162pub use clustering_advanced::{
163    SpectralClustering, MeanShift, MiniBatchKMeans, AffinityPropagation,
164};
165pub use clustering_more::{OPTICS, BIRCH, HDBSCAN};
166
167// Re-exports: Mixture Models
168pub use mixture::{GaussianMixture, BayesianGaussianMixture, CovarianceType};
169
170// Re-exports: Decomposition
171pub use decomposition::{PCA, SVD, NMF};
172pub use decomposition_advanced::{FactorAnalysis, FastICA, SparsePCA, DictionaryLearning};
173
174// Re-exports: Neighbors
175pub use neighbors::{KNeighborsClassifier, KNeighborsRegressor};
176
177// Re-exports: SVM
178pub use svm::{SVC, SVR, Kernel as SVMKernel};
179
180// Re-exports: Kernel Methods
181pub use kernel::{KernelRidge, KernelPCA, Nystrom, Kernel};
182
183// Re-exports: Naive Bayes
184pub use naive_bayes::{GaussianNB, MultinomialNB, BernoulliNB, ComplementNB};
185
186// Re-exports: Bayesian
187pub use bayesian::{BayesianRidge, ARDRegression};
188
189// Re-exports: Discriminant Analysis
190pub use discriminant_analysis::{LinearDiscriminantAnalysis, QuadraticDiscriminantAnalysis};
191
192// Re-exports: Gaussian Processes
193pub use gaussian_process::{GaussianProcessRegressor, GaussianProcessClassifier, GPKernel};
194
195// Re-exports: Neural Networks
196pub use neural_network::{Perceptron, MLPClassifier, MLPRegressor, Activation};
197pub use rbf_network::{RBFNetwork, RBFClassifier};
198
199// Re-exports: Manifold Learning
200pub use manifold::{TSNE, MDS, Isomap, LocallyLinearEmbedding};
201
202// Re-exports: Outlier Detection
203pub use outlier_detection::{LocalOutlierFactor, OneClassSVM, EllipticEnvelope};
204
205// Re-exports: Feature Selection
206pub use feature_selection::{VarianceThreshold, SelectKBest, RFE, ScoreFunction};
207
208// Re-exports: Preprocessing
209pub use preprocessing::{
210    StandardScaler, MinMaxScaler, Normalizer, 
211    LabelEncoder, OneHotEncoder, train_test_split,
212};
213pub use polynomial::{
214    PolynomialFeatures, SplineTransformer, PowerTransformer, QuantileTransformer,
215    PowerMethod, OutputDistribution,
216};
217
218// Re-exports: Multiclass
219pub use multiclass::{OneVsRestClassifier, OneVsOneClassifier, OutputCodeClassifier, ClassifierChain};
220
221// Re-exports: Metrics
222pub use metrics::{
223    // Classification
224    accuracy_score, precision_score, recall_score, f1_score, 
225    confusion_matrix, roc_auc_score, classification_report,
226    // Regression
227    mean_squared_error, root_mean_squared_error, mean_absolute_error, 
228    r2_score, mean_absolute_percentage_error, explained_variance_score,
229    // Clustering
230    silhouette_score, davies_bouldin_score,
231};
232pub use metrics_advanced::{
233    log_loss, log_loss_multiclass, hinge_loss, squared_hinge_loss,
234    cohen_kappa_score, matthews_corrcoef, adjusted_rand_score,
235    normalized_mutual_info_score, fowlkes_mallows_score,
236    calinski_harabasz_score,
237};
238
239// Re-exports: Model Selection
240pub use model_selection::{
241    KFold, StratifiedKFold, LeaveOneOut, TimeSeriesSplit,
242    cross_val_score, parameter_grid, shuffle_split,
243};
244
245// Re-exports: Calibration
246pub use calibration::{IsotonicRegression, PlattScaling, CalibratedClassifier};
247
248// Re-exports: Semi-supervised
249pub use semi_supervised::{LabelPropagation, LabelSpreading, SelfTrainingClassifier};
250
251// Re-exports: Imbalanced Learning
252pub use imbalanced::{RandomOverSampler, RandomUnderSampler, SMOTE, BorderlineSMOTE, ADASYN, SamplingStrategy};
253
254// Re-exports: Time Series
255pub use time_series::{
256    SimpleExponentialSmoothing, HoltLinear, HoltWinters, SeasonalType,
257    ARIMA, MovingAverage, EWMA,
258};
259pub use time_series_extended::SARIMA;
260
261// Re-exports: Extended Linear Models
262pub use linear_sgd::{SGDClassifier, SGDRegressor, SGDLoss, SGDRegressorLoss, Penalty, LearningRate};
263
264// Re-exports: Extended Decomposition
265pub use decomposition_incremental::IncrementalPCA;
266
267// Re-exports: Extended Preprocessing
268pub use preprocessing_extended::{RobustScaler, MaxAbsScaler, OrdinalEncoder};
269
270// Re-exports: Extended Model Selection
271pub use model_selection_extended::{
272    RandomizedSearchCV, ParamDistribution, RandomizedSearchResult, CVResult,
273    GroupKFold, RepeatedKFold, StratifiedShuffleSplit, Scoring,
274    learning_curve, validation_curve,
275};
276
277// Re-exports: Deep Learning
278// NOTE: Deep module disabled - has compilation issues
279/*
280pub use deep::{
281    // Layers
282    Dense, Dropout, BatchNorm, LayerNorm, Embedding, Flatten,
283    // CNN
284    Conv2d, Conv1d, Conv3d, MaxPool2d, AvgPool2d, GlobalAvgPool2d,
285    BatchNorm2d, GroupNorm,
286    // RNN
287    RNNCell, LSTMCell, GRUCell, RNN, LSTM, GRU,
288    // Transformer
289    ScaledDotProductAttention, MultiHeadAttention, PositionalEncoding,
290    FeedForward, TransformerLayerNorm, TransformerEncoderLayer, TransformerEncoder,
291    TransformerDecoderLayer, TransformerDecoder, Transformer,
292    PatchEmbedding, VisionTransformer,
293    // Optimizers
294    SGD, Adam, AdamW, RMSprop, AdaGrad, Adadelta, Adamax, NAdam, RAdam,
295    // Losses
296    MSELoss, CrossEntropyLoss, BCELoss, BCEWithLogitsLoss, HuberLoss as DeepHuberLoss, 
297    L1Loss, HingeLoss as DeepHingeLoss, KLDivLoss, Reduction,
298    FocalLoss, DiceLoss, TverskyLoss, LovaszLoss, ContrastiveLoss, TripletLoss,
299    CenterLoss, LabelSmoothingLoss,
300    // Activations
301    ReLU, LeakyReLU, PReLU, ELU, SELU, Sigmoid, Tanh, Softmax, GELU, Swish, Mish, Hardswish,
302};
303*/
304
305// Re-exports: NLP
306pub use nlp::{
307    WordTokenizer, CharTokenizer, BPETokenizer,
308    TfidfVectorizer, Word2Vec,
309};
310
311// Re-exports: Vision
312pub use vision::{
313    ImageAugmentation, ImageNormalization, ImageResize, ImageCrop,
314    RandomCrop, ColorJitter, Interpolation,
315};
316
317// Re-exports: Distributed Training
318pub use distributed::{
319    DistributedStrategy, CommunicationBackend, GradientAggregation,
320    DistributedConfig, DataParallelTrainer, DistributedDataLoader,
321    GradientCompression, CompressionMethod, RingAllReduce,
322};
323
324// Re-exports: GPU Acceleration
325pub use gpu::{
326    DeviceType, DeviceInfo, GPUContext, GPUTensor, GPUOps,
327    GPUMemoryManager, AutoMixedPrecision,
328};
329
330// Re-exports: Neural Architecture Search
331pub use nas::{
332    Operation, Cell, DARTS, ENAS, ProgressiveNAS, HardwareAwareNAS,
333};
334
335// Re-exports: AutoML
336// Note: AutoML types can be accessed via ghostflow_ml::automl::*
337// pub use automl::{
338//     AutoML, AutoMLConfig, OptimizationMetric,
339// };
340// pub use automl::{
341//     ModelType, TrainedModel, TaskType, MetaLearner,
342// };
343
344