Cross-validation summary
Review fold balance, stability, risks, and exportable results.
Dataset and holdout allocation
Counts and percentages show the data available before fold creation.
| Class | Total | Original % | Holdout test | CV pool | CV pool % |
|---|
Training and validation distribution
Each row represents one fold or stratified shuffle split.
Show assigned sample indexes
Stratified versus standard K-Fold
Lower deviation means validation folds follow the original class ratios more closely.
| Method | Mean class-ratio deviation | Maximum deviation | Empty class-fold cells | Interpretation |
|---|
Aggregated metric results
Statistics use the fold-level values entered below.
| Metric | Count | Mean | Median | Minimum | Maximum | Range | Std. deviation | Variance | Std. error | Confidence interval | CV | Best fold | Worst fold |
|---|
Combined confusion matrix and class metrics
Precision, recall, and F1-score are calculated from optional confusion counts.
Charts
Use the charts to inspect balance, deviation, performance, and repetition stability.
Original class distribution
Validation classes by fold
Training versus validation size
Class-ratio deviation
Fold metric performance
Metric confidence intervals
Repetition stability
Merged report data
Copy this text into notes, experiments, or model documentation.
Core calculations
These formulas summarise fold sizing and score variability.
Validation samples per fold ≈ N ÷ KClass samples per fold ≈ Nc ÷ KMean score = Σsi ÷ KSample standard deviation = √[Σ(si − mean)² ÷ (K − 1)]Standard error = standard deviation ÷ √KCalculation steps
- Enter class counts, percentages, or CSV labels.
- Choose the validation method and fold count.
- Set repeats, shuffling, seed, and holdout percentage.
- Optionally paste fold metrics and confusion counts.
- Calculate, inspect warnings, compare methods, and export.
Common classification scenarios
| Scenario | Class counts | Suggested folds | Main concern |
|---|---|---|---|
| Balanced binary | 50, 50 | 5 or 10 | General stability |
| Imbalanced binary | 24, 476 | 5 | Minority representation |
| Three classes | 120, 75, 45 | 5 | Multi-class balance |
| Small minority | 4, 196 | At most 4 | Empty minority folds |
| Repeated validation | 90, 60, 30 | 5 repeated | Variance estimation |
| Ten-fold example | 130, 170 | 10 | Smaller validation folds |
Important cross-validation practices
Stratification preserves class proportions across validation folds. It is especially useful for imbalanced classification datasets. It does not repair weak labels or leakage.
Fit preprocessing inside every training fold only. This includes scaling, selection, encoding, and resampling. Applying them globally can inflate validation scores.
Group-aware data needs grouped stratification methods. Multilabel targets need iterative multilabel stratification. Ordinary stratification may separate related samples incorrectly.
Leave-one-out classification can produce unstable class coverage. Repeated stratification usually estimates variability more clearly. Use an untouched test set for final reporting.
Stratified cross-validation questions
What does stratified cross-validation preserve?
It keeps each fold close to the dataset’s class proportions.
How many folds should I use?
Five or ten folds are common. The smallest class limits the safe maximum.
What happens when a class has fewer samples than folds?
Some validation folds cannot contain that class. Reduce the fold count.
Should I shuffle before splitting?
Usually yes, unless the data order carries time or sequence meaning.
Why use repeated stratified validation?
Repeats reduce dependence on one random split and expose score variance.
Can stratification prevent data leakage?
No. Pipelines and group-aware splitting are still required.
Should oversampling happen before cross-validation?
No. Apply oversampling only inside each training fold.
Can I use this calculator for regression?
Direct class stratification is for classification. Regression requires binned targets or other strategies.
What indicates unstable model performance?
Large standard deviation, wide confidence intervals, and inconsistent fold scores indicate instability.