20 — Core Math

Cross-Validation#

Evaluation✓ Mathematical
◆ The PatternReliable model evaluation by rotating which data is used for testing

k-fold cross-validation averages performance over k splits for a more reliable estimate than a single train/test split.

CV Score = (1/k) · Σᵢ score(model_i, fold_i)
Train k models, each evaluated on a different held-out fold
// k-fold cross-validation — click to cycle through folds
k folds5
1

Split data into k folds

Typically k=5 or k=10

2

Train on k−1 folds

One fold held out as validation set

3

Evaluate on held-out fold

Record metric (accuracy, F1, etc.)

4

Average k scores

→ final CV estimate with confidence interval

Pattern bridge: Rotating train/test splits prevents overfitting to one sample — the statistical version of sampling distributions. In markets, recency bias is what happens when you only test on the latest fold.
← Previous
Bayes' Theorem
Open in the full reader, with the topic sidebar →