solow 0.7.4

The comprehensive statistics and machine learning stack for Rust. Regression, generalized linear models, discrete choice, time series, state space, survival analysis, mixed effects, Bayesian inference, clustering, tree ensembles, SVM, neural networks, kernel methods, dimensionality reduction, and change point detection. 54 focused crates, memory safe, pure Rust.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
//! # Solow
//!
//! The comprehensive statistics and machine learning stack for Rust.
//! 54 focused crates. Memory safe. Deterministic. Pure Rust.
//!
//! Linear and generalized linear models, discrete choice, robust
//! regression, time series and state-space models, survival analysis,
//! mixed effects, Bayesian inference, clustering, tree ensembles,
//! support vector machines, neural networks, kernel methods,
//! dimensionality reduction, and change-point detection.
//!
//! This umbrella crate re-exports the full public API of the workspace
//! behind a single ergonomic [`prelude`]. Depend on `solow` once and you
//! have every module reachable at `solow::<module>::*`:
//! [`regression`], [`glm`], [`discrete`], [`stats`], [`tsa`],
//! [`statespace`], [`var`], [`regime`], [`mixed`], [`gee`], [`gam`],
//! [`duration`], [`multivariate`], [`cross_decomposition`],
//! [`covariance`], [`cluster`], [`tree`], [`ensemble`], [`svm`],
//! [`neural`], [`naive_bayes`], [`neighbors`], [`discriminant`],
//! [`decomposition`], [`manifold`], [`kernel_approx`],
//! [`semi_supervised`], [`multi`], [`calibration`], [`gp`], [`cv`],
//! [`metrics`], [`pipeline`], [`feature_selection`], [`preprocessing`],
//! [`text`], [`impute`], [`datasets`], [`bayes`], [`emplike`],
//! [`copula`], [`formula`], [`fit`], [`nonparametric`], [`robust`],
//! [`othermod`], [`distributions`], [`viz`], [`graphics`], [`summary`].
//!
//! ## Why Solow
//!
//! * **Memory safe.** `#![forbid(unsafe_code)]` on every crate.
//! * **Deterministic.** Every stochastic estimator uses a portable
//!   MMIX-LCG PRNG. A fixed seed reproduces bit-identical fits across
//!   runs, platforms, and CI hosts.
//! * **Cross-verified.** Every deterministic estimator is checked
//!   against committed golden reference fixtures on every CI run.
//!   Closed-form solvers agree bit-wise to `1e-10`.
//! * **Pure Rust.** No system LAPACK. No BLAS. No Python runtime.
//!   No C dependencies beyond libc.
//! * **Single binary.** Deploys anywhere Rust runs, including
//!   WebAssembly.
//!
//! ## Quick start
//!
//! ```
//! use solow::prelude::*;
//! use ndarray::array;
//!
//! let y = array![2.5, 3.4, 4.7, 5.1, 6.5];
//! let x = array![[1.0, 1.0], [1.0, 2.0], [1.0, 3.0], [1.0, 4.0], [1.0, 5.0]];
//! let res = LinearModel::ols(y, x).unwrap().fit().unwrap();
//! assert!(res.rsquared > 0.98);
//! ```
//!
//! The [`prelude`] pulls in the everyday surface: error and numeric
//! types, the formula-driven fit helpers (`ols`, `wls`, `gls`, `glm`,
//! `logit`, `probit`, `poisson`), the workhorse estimators
//! ([`LinearModel`](regression::LinearModel), [`Glm`](glm::Glm),
//! [`Logit`](discrete::Logit), [`Svc`](svm::Svc),
//! [`RandomForestClassifier`](ensemble::RandomForestClassifier),
//! [`GradientBoostingRegressor`](ensemble::GradientBoostingRegressor),
//! [`MlpClassifier`](neural::MlpClassifier), [`KMeans`](cluster::KMeans),
//! [`Dbscan`](cluster::Dbscan), [`Pca`](multivariate::Pca),
//! [`Sarimax`](statespace::Sarimax), [`Var`](var::Var), and dozens
//! more), the everyday metrics (`mean_squared_error`, `r2_score`,
//! `accuracy_score`, `roc_auc_score`, `log_loss`,
//! `classification_report`, `silhouette_score`, `pairwise_distances`),
//! and the cross-validation splitters and helpers ([`KFold`](cv::KFold),
//! [`StratifiedKFold`](cv::StratifiedKFold),
//! [`TimeSeriesSplit`](cv::TimeSeriesSplit),
//! [`PurgedKFold`](cv::PurgedKFold), `cross_val_score`, `bootstrap_ci`).
//!
//! ## Beyond the classical stack
//!
//! Capabilities that few libraries expose as first-class modules:
//!
//! * **Change-point detection**: `pelt`
//!   (Killick, Fearnhead, Eckley 2012), `cusum`, `binary_segmentation`.
//! * **Volatility**: `Garch11` with iterated multi-step variance
//!   forecast.
//! * **Extreme value analysis**: `Gev`, `Gpd` with `return_level(T)`
//!   and peaks-over-threshold fit.
//! * **Effect sizes**: Cohen d, Hedges g, Glass delta, eta squared,
//!   omega squared, Cliff delta, Cramer V.
//! * **Meta-analysis**: fixed-effect and DerSimonian-Laird
//!   random-effects with Cochran Q, I², τ².
//! * **Control charts**: two-sided CUSUM and EWMA (Roberts 1959) with
//!   signed alarm streams.
//! * **Block bootstrap**: moving, circular, and stationary variants
//!   for time series.
//! * **Conformal prediction**: `SplitConformal`, `JackknifePlus`
//!   for distribution-free prediction intervals.
//!
//! ## Correctness
//!
//! Correctness is the product. Solow ships a multi-layer verification
//! stack.
//!
//! * **Reference fixtures**: every deterministic estimator has a
//!   committed golden fixture generated from a well-known reference
//!   implementation. A Rust replay test re-checks each fixture on every
//!   CI run.
//! * **NIST StRD certified cases**: re-run on every CI. Worst-case
//!   certified relative error across the suite is `2.5e-10`. Longley
//!   (cond ~10¹⁰) matches certified coefficients to `~1e-13` because
//!   the QR/SVD path never forms `XᵀX`.
//! * **Zero unsafe**: `#![forbid(unsafe_code)]` on every crate.
//! * **Deterministic PRNG**: every stochastic estimator uses a portable
//!   MMIX-LCG. A fixed seed produces bit-identical output across runs,
//!   platforms, and CI hosts.
//!
//! Run the full CI locally with `cargo test --workspace` (1000+ tests).

pub use solow_bayes as bayes;
pub use solow_calibration as calibration;
pub use solow_cluster as cluster;
pub use solow_copula as copula;
pub use solow_core as core;
pub use solow_covariance as covariance;
pub use solow_cross_decomposition as cross_decomposition;
pub use solow_cv as cv;
pub use solow_datasets as datasets;
pub use solow_decomposition as decomposition;
pub use solow_discrete as discrete;
pub use solow_discriminant as discriminant;
pub use solow_distributions as distributions;
pub use solow_duration as duration;
pub use solow_emplike as emplike;
pub use solow_ensemble as ensemble;
pub use solow_feature_selection as feature_selection;
pub use solow_fit as fit;
pub use solow_formula as formula;
pub use solow_gam as gam;
pub use solow_gee as gee;
pub use solow_glm as glm;
pub use solow_gp as gp;
pub use solow_graphics as graphics;
pub use solow_impute as impute;
pub use solow_kernel_approx as kernel_approx;
pub use solow_linalg as linalg;
pub use solow_manifold as manifold;
pub use solow_metrics as metrics;
pub use solow_mixed as mixed;
pub use solow_multi as multi;
pub use solow_multivariate as multivariate;
pub use solow_naive_bayes as naive_bayes;
pub use solow_neighbors as neighbors;
pub use solow_neural as neural;
pub use solow_nonparametric as nonparametric;
pub use solow_optimize as optimize;
pub use solow_othermod as othermod;
pub use solow_pipeline as pipeline;
pub use solow_preprocessing as preprocessing;
pub use solow_regime as regime;
pub use solow_regression as regression;
pub use solow_robust as robust;
pub use solow_semi_supervised as semi_supervised;
pub use solow_statespace as statespace;
pub use solow_stats as stats;
pub use solow_summary as summary;
pub use solow_svm as svm;
pub use solow_text as text;
pub use solow_tree as tree;
pub use solow_tsa as tsa;
pub use solow_var as var;
pub use solow_viz as viz;

pub use ndarray;

/// The recommended glob-import for day-to-day use.
///
/// Brings into scope:
///
/// * the shared error / result / numeric types from [`solow_core`];
/// * the ergonomic formula-driven fit helpers from [`solow_fit`]
///   (`ols`, `wls`, `gls`, `glm`, `logit`, `probit`, `poisson`);
/// * the workhorse estimator types, [`LinearModel`](solow_regression::LinearModel),
///   [`Glm`](solow_glm::Glm), [`Logit`](solow_discrete::Logit),
///   [`Probit`](solow_discrete::Probit), [`Poisson`](solow_discrete::Poisson)
///   and their result structs;
/// * the [`solow_glm`] families and links;
/// * the two most common design-matrix helpers,
///   [`add_constant`](solow_core::tools::add_constant) and
///   [`HasConstant`](solow_core::tools::HasConstant);
/// * the everyday model-evaluation metrics: `mean_squared_error`,
///   `root_mean_squared_error`, `mean_absolute_error`, `r2_score`,
///   `accuracy_score`, `roc_auc_score`, `log_loss`.
pub mod prelude {
    // ndarray essentials.
    pub use ndarray::{array, s, Array1, Array2, ArrayView1, ArrayView2, Axis};

    // Core error, numeric aliases, common tools.
    pub use solow_core::prelude::*;

    // Ergonomic formula-driven fit surface.
    pub use solow_fit::{glm, gls, logit, ols, poisson, probit, wls, DataFrame, NamedFit};

    // Workhorse estimators.
    pub use solow_discrete::{DiscreteResults, LogisticRegressionCV, Logit, Poisson, Probit};
    pub use solow_glm::{
        Family, GammaRegressor, Glm, GlmResults, Link, PoissonRegressor, TweedieRegressor,
    };
    pub use solow_regression::{LinearModel, LinearResults};

    // Formula compilation for the manual path.
    pub use solow_formula::{build, DesignOutput};

    // The most common metrics and the pairwise kernel and distance surface.
    pub use solow_metrics::{
        accumulated_local_effects, accuracy_score, adjusted_mutual_info_score, adjusted_rand_score,
        average_precision_score, binary_focal_loss, calinski_harabasz_score, chi2_kernel,
        classification_report, cliffs_delta, cohens_d, completeness_score, cosine_similarity,
        cramers_v, davies_bouldin_score, diebold_mariano, eta_squared, expected_calibration_error,
        fowlkes_mallows_score, friedman_test, giacomini_white_test, glass_delta, hedges_g,
        homogeneity_score, huber_loss, laplacian_kernel, linear_kernel, log_cosh_loss, log_loss,
        mean_absolute_error, mean_squared_error, multiclass_brier_score, multiclass_focal_loss,
        nemenyi_critical_difference, normalized_mutual_info_score, omega_squared,
        pairwise_distances, partial_dependence, permutation_importance, polynomial_kernel,
        psis_loo, r2_score, ranked_probability_score, rbf_kernel, roc_auc_score,
        root_mean_squared_error, sigmoid_kernel, silhouette_score, top_label_calibration_error,
        v_measure_score, waic, wilcoxon_signed_rank, AccumulatedLocalEffects, Average, BinStrategy,
        ClassificationReport, ClassificationRow, DmLoss, FeatureImportance, FriedmanResult,
        IsotonicRegression, JackknifePlus, MiAverage, MulticlassAuc, PairwiseMetric,
        PartialDependence, PlattScaling, PredictionInterval, PsisLooResult, RegressionReport,
        SplitConformal, TemperatureScaling, WaicResult, WilcoxonResult,
    };

    // Dataset generators and lightweight utility helpers
    // (class-weight and resampling helpers).
    pub use solow_datasets::{
        compute_class_weight, compute_sample_weight, load_breast_cancer, load_diabetes, load_iris,
        load_wine, make_blobs, make_circles, make_classification, make_low_rank_matrix, make_moons,
        make_regression, make_swiss_roll, resample_indices_no_replace,
        resample_indices_with_replace,
    };

    // Cross-validation, cross-val scoring, and bootstrap, including
    // repeated / leave-p-out splitters and learning / validation /
    // permutation-test curves.
    pub use solow_cv::{
        bootstrap_ci, circular_block_bootstrap_indices, cross_val_score, learning_curve,
        moving_block_bootstrap_indices, permutation_test_score, stationary_bootstrap_indices,
        validation_curve, BootstrapCi, BootstrapMethod, CombinatorialPurgedKFold, CrossValScores,
        GroupKFold, GroupShuffleSplit, KFold, LeaveOneOut, LeavePOut, PurgedKFold, RepeatedKFold,
        RepeatedStratifiedKFold, ShuffleSplit, Split, Splitter, StratifiedGroupKFold,
        StratifiedKFold, StratifiedShuffleSplit, TimeSeriesSplit,
    };

    // Time-series analysis, AR, ARMA, cointegration, unit-root, and filters.
    pub use solow_tsa::{
        binary_segmentation, coint, cusum, ewma, kpss, pelt, AutoReg, CusumAlarm, EwmaAlarm,
        EwmaResult, ExponentialSmoothing, Garch11, Holt, SimpleExpSmoothing,
    };

    // Multivariate analysis, PCA, factor analysis, MANOVA, canonical correlation.
    pub use solow_multivariate::{CanCorr, Factor, Manova, Pca};

    // Vector time-series, VAR, VECM, SVAR.
    pub use solow_var::{Svar, Var, Vecm};

    // State-space and structural time series.
    pub use solow_statespace::{
        DynamicFactor, MvStateSpace, Sarimax, StateSpace, UnobservedComponents,
    };

    // Nonparametric, LOWESS, KDE, kernel regression.
    pub use solow_nonparametric::{lowess, KdeUnivariate, KernelReg};

    // Regime-switching models (Markov).
    pub use solow_regime::{MarkovAutoregression, MarkovRegression, MarkovResults};

    // Quantile regression, GLSAR, penalised linear models, Bayesian ridge,
    // ARD, LARS / OMP, robust regressions, multi-task, and stochastic
    // gradient descent-style online learners.
    pub use solow_regression::{
        ARDRegression, BayesianRidge, DummyClassifier, DummyClassifierStrategy, DummyRegressor,
        DummyRegressorStrategy, ElasticNet, ElasticNetCV, Glsar, HuberRegressor,
        InformationCriterion, KernelRidge, Lars, Lasso, LassoCV, LassoLars, LassoLarsIC,
        MultiTaskElasticNet, MultiTaskLasso, OrthogonalMatchingPursuit,
        PassiveAggressiveClassifier, PassiveAggressiveRegressor, Perceptron, QuantReg,
        RansacRegressor, Ridge, RidgeCV, RidgeClassifier, RidgeClassifierCV, RidgeKernel,
        SgdClassifier, SgdLoss, SgdPenalty, SgdRegressor, TheilSenRegressor,
    };

    // Missing-value imputation.
    pub use solow_impute::{IterativeImputer, KnnImputer, SimpleImputer, SimpleStrategy};

    // Preprocessing (scalers, encoders, feature construction, power/quantile,
    // binarizer, label / multilabel binarizer, function transformer, spline, target encoder).
    pub use solow_preprocessing::{
        BinStrategy as PreprocBinStrategy, Binarizer, FunctionTransformer, KBinsDiscretizer,
        LabelBinarizer, LabelEncoder, MaxAbsScaler, MinMaxScaler, MultiLabelBinarizer, NormKind,
        Normalizer, OneHotEncoder, OrdinalEncoder, PolynomialFeatures, PowerMethod,
        PowerTransformer, QuantileOutput, QuantileTransformer, RobustScaler, SplineTransformer,
        StandardScaler, TargetEncoder,
    };

    // Unsupervised clustering.
    pub use solow_cluster::{
        AffinityPropagation, AgglomerativeClustering, Birch, BisectingKMeans, CovType, Dbscan,
        DbscanResult, DendrogramNode, GaussianMixture, Hdbscan, KMeans, KMeansInit, KMeansResult,
        Linkage, MeanShift, MiniBatchKMeans, Optics, PointRole, SpectralClustering,
    };

    // Nearest neighbours (KDTree + BallTree + classifiers/regressors + centroid
    // + LOF + multi-variate KernelDensity).
    pub use solow_neighbors::{
        BallTree, KNeighborsClassifier, KNeighborsRegressor, KdTree, KdeKernel, KernelDensity,
        LocalOutlierFactor, NearestCentroid, RadiusNeighborsClassifier, RadiusNeighborsRegressor,
        WeightKind,
    };

    // Decision trees (CART + Extra-Trees).
    pub use solow_tree::{
        ClassificationCriterion, DecisionTreeClassifier, DecisionTreeRegressor,
        ExtraTreeClassifier, ExtraTreeRegressor, RegressionCriterion, TreeParams,
    };

    // Ensembles.
    pub use solow_ensemble::{
        AdaBoostClassifier, AdaBoostRegressor, BaggingClassifier, BaggingRegressor,
        ExtraTreesClassifier, ExtraTreesRegressor, GradientBoostingClassifier,
        GradientBoostingRegressor, HistGradientBoostingClassifier, HistGradientBoostingRegressor,
        IsolationForest, RandomForestClassifier, RandomForestRegressor, StackingClassifier,
        StackingRegressor, VotingClassifier, VotingMode, VotingRegressor,
    };

    // Naive Bayes (5 varyant).
    pub use solow_naive_bayes::{
        BernoulliNB, CategoricalNB, ComplementNB, GaussianNB, MultinomialNB,
    };

    // Discriminant analysis.
    pub use solow_discriminant::{LinearDiscriminantAnalysis, QuadraticDiscriminantAnalysis};

    // Feature selection.
    pub use solow_feature_selection::{
        score_f_classif, score_f_regression, Rfe, SelectFdr, SelectFpr, SelectFwe, SelectKBest,
        SelectPercentile, SequentialFeatureSelector, SfsDirection, VarianceThreshold,
    };

    // Pipelines and hyperparameter search, full-grid, random,
    // successive-halving variants.
    pub use solow_pipeline::{
        ColumnTransformer, ColumnTransformerStep, FeatureUnion, FeatureUnionStep, GridSearchCV,
        HalvingConfig, HalvingGridSearchCV, HalvingRandomSearchCV, ParamGrid, Pipeline,
        RandomizedSearchCV, SearchResult, Step, TransformedTargetRegressor,
    };

    // Support vector machines (linear + kernel + ν-SVM + one-class).
    pub use solow_svm::{
        KernelKind as SvmKernelKind, LinearSvc, LinearSvr, NuSvc, NuSvr, OneClassSvm, Svc, Svr,
    };

    // Neural networks (small MLPs + BernoulliRBM).
    pub use solow_neural::{Activation, BernoulliRbm, MlpClassifier, MlpRegressor, Solver};

    // Manifold learning.
    pub use solow_manifold::{Isomap, LocallyLinearEmbedding, SpectralEmbedding, Tsne, MDS};

    // Decomposition, Kernel PCA / ICA / NMF / MiniBatchNMF / TruncatedSVD /
    // IncrementalPCA / SparsePCA / DictionaryLearning / MiniBatchDictionaryLearning /
    // LDA / Gaussian & Sparse random projections + Johnson-Lindenstrauss helper.
    pub use solow_decomposition::{
        johnson_lindenstrauss_min_dim, DictionaryLearning, FastIca, GaussianRandomProjection,
        IcaFun, IncrementalPCA, KernelKind, KernelPca, LatentDirichletAllocation,
        MiniBatchDictionaryLearning, MiniBatchNmf, Nmf, SparsePCA, SparseRandomProjection,
        TruncatedSVD,
    };

    // Covariance estimators, sample, shrinkage, MCD, graphical lasso, elliptic envelope.
    pub use solow_covariance::{
        EllipticEnvelope, EmpiricalCovariance, GraphicalLasso, LedoitWolf, MinCovDet, Oas,
        ShrunkCovariance,
    };

    // Calibration.
    pub use solow_calibration::{CalibratedClassifierCV, Method as CalibrationMethod};

    // Cross-decomposition, PLS / CCA.
    pub use solow_cross_decomposition::{PLSCanonical, PLSRegression, CCA, PLSSVD};

    // Kernel approximation.
    pub use solow_kernel_approx::{
        AdditiveChi2Sampler, Nystroem, PolynomialCountSketch, RBFSampler, SkewedChi2Sampler,
    };

    // Gaussian processes.
    pub use solow_gp::{GaussianProcessClassifier, GaussianProcessRegressor};

    // Semi-supervised.
    pub use solow_semi_supervised::{LabelPropagation, LabelSpreading, SelfTrainingClassifier};

    // Multi-class / multi-output.
    pub use solow_multi::{
        ClassifierChain, MultiOutputClassifier, MultiOutputRegressor, OneVsOneClassifier,
        OneVsRestClassifier, OutputCodeClassifier, RegressorChain,
    };

    // Text feature extraction.
    pub use solow_text::{
        CountVectorizer, DictVectorizer, FeatureHasher, HashingVectorizer, TfidfVectorizer,
    };

    // Duration / survival.
    pub use solow_duration::{PHReg, PHRegResults, SurvfuncRight};

    // Mixed-effects and GAM.
    pub use solow_mixed::MixedLm;

    // GEE.
    pub use solow_gee::{Gee, GeeResults};

    // Robust regression.
    pub use solow_robust::Rlm;

    // The most common stats tests, the ones a regression analyst reaches for
    // right after inspecting the coefficient table, plus non-parametric
    // two/k-sample tests and the three canonical correlation coefficients.
    pub use solow_stats::{
        anderson_darling, anova_lm, bartlett, chi2_contingency, describe, durbin_watson, f_test,
        fligner, het_white, jarque_bera, kendalltau, kruskal, ks_2samp, levene, mannwhitneyu,
        mcnemar, meta_fixed_effect, meta_random_effects, multipletests, pearsonr, runs_test,
        shapiro_wilk, spearmanr, wald_test, CorrelationResult, DescrStatsW, FTestResult, GofResult,
        LeveneCenter, MetaModel, MetaResult, MetaStudy, NpTestResult, VarianceTestResult,
        WaldResult,
    };
}