Expand description
§solow-cv
Cross-validation, resampling, and bootstrap for the Solow statistical stack.
The crate provides three composable layers:
-
Splitters —
KFold,StratifiedKFold,TimeSeriesSplit,LeaveOneOut, andShuffleSplitbehind the sharedSplittertrait. Every splitter emits validatedVec<Split>fold lists that a caller can iterate, index, or run in parallel. -
Cross-validated scoring —
cross_val_scoreruns afit_and_scorecallback across every fold and returns the per-fold scores with mean, unbiased standard deviation, and standard error. -
Bootstrap confidence intervals —
bootstrap_ciresamples with replacement and returns a percentile, reverse-percentile (“basic”), or Efron BCa confidence interval for any scalar statistic of a sample.
use ndarray::array;
use solow_cv::{KFold, Splitter};
let y = array![1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0];
let kf = KFold::new(5)?.shuffle(false);
for split in kf.split(y.len())? {
let (train, test) = (split.train, split.test);
assert_eq!(train.len() + test.len(), y.len());
// Fit on `y.select(Axis(0), &train)`; score on the test rows.
}§Determinism
Random splits and bootstrap resamples use a well-tested 64-bit linear-congruential generator (Numerical Recipes’ MMIX constants), seeded by the caller. The stream is bit-for-bit portable across platforms; a fixed seed always produces the same folds and replicates.
Modules§
- prelude
- Commonly used imports.
Structs§
- Bootstrap
Ci - A point estimate together with its bootstrap confidence interval.
- Combinatorial
PurgedK Fold - Combinatorial Purged K-Fold cross-validation with an optional embargo.
- Cross
ValScores - Per-fold scores plus their summary.
- GroupK
Fold - Group-aware K-fold cross-validation.
- Group
Shuffle Split - GroupShuffleSplit — train/test split at the group level.
- KFold
- K-fold cross-validator with
n_splitsequal-sized folds. - Leave
OneOut - Leave-one-out cross-validation.
- LeaveP
Out - Leave-P-Out cross-validation. Emits
C(n, p)folds; use with care on large samples. - PurgedK
Fold - K-fold time-series splitter with a purge band and an optional embargo.
- RepeatedK
Fold - Repeated K-Fold cross-validation.
- Repeated
StratifiedK Fold - Repeated Stratified K-Fold.
- Shuffle
Split - Repeated random train / test splits at a chosen test fraction.
- Split
- One train / test fold. Indices are sample positions (
0..n) that a caller hands tondarray::selector a slice-based indexing helper. - Stratified
GroupK Fold - Group-aware, class-stratified K-fold.
- StratifiedK
Fold - K-fold cross-validator that preserves the per-class label distribution in every fold.
- Stratified
Shuffle Split - StratifiedShuffleSplit.
- Time
Series Split - Expanding-window walk-forward validation for time series.
Enums§
- Bootstrap
Method - Bootstrap confidence-interval method.
Traits§
- Splitter
- Every splitter produces a validated list of folds.
Functions§
- bootstrap_
ci - Compute a bootstrap confidence interval for
statistic(indices)on a sample of sizen. - circular_
block_ bootstrap_ indices - Circular block bootstrap — wraps blocks around the end of the sample.
- cross_
val_ score - Run
fit_and_scoreon every fold asplitterproduces and collect the per-fold scores. - cross_
val_ score_ from_ folds - Variant of
cross_val_scorethat takes a pre-computed list of folds directly — useful when the caller wants to share the same folds between multiple scoring passes (e.g. hyperparameter sweeps). - cross_
val_ score_ parallel - Parallel counterpart of
cross_val_score— evaluates every fold on a rayon thread pool and returns the scores in fold order. - learning_
curve - Learning-curve evaluator — score at increasing training-set sizes.
- moving_
block_ bootstrap_ indices - Moving-block bootstrap indices — a resample of length
nbuilt from⌈n / block_len⌉overlapping blocks of lengthblock_len. - permutation_
test_ score - Permutation-test-score — significance test for a cross-validated score.
- stationary_
bootstrap_ indices - Stationary bootstrap — Politis-Romano (1994) — block lengths drawn
from
Geom(p)wherep = 1 / expected_block_len. - validation_
curve - Validation-curve evaluator — score at increasing values of a hyper-parameter.