2.6.4 · D1Model Evaluation & Selection

Foundations — K-fold cross-validation

2,040 words9 min readBack to topic

Before you can read the parent note K-fold Cross-Validation, you need to earn every symbol it throws at you. This page builds each one from nothing — plain words first, then a picture, then why the topic needs it. Read top to bottom; each idea leans on the one above it.


0. The scene: a dataset is a stack of cards

Look at the figure: the tall stack on the left is , and is the count written beside it.

Figure — K-fold cross-validation

Why the topic needs this: cross-validation is entirely about how we cut up this stack. If you don't picture as a physical stack of cards, none of the cutting will make sense.


1. A "sample" and why we care about unseen ones

Here is the whole reason this topic exists. When we build a model, we want to know:

"How well will it answer cards it has never studied?"

If you test a student using the exact questions they revised from, they'll look brilliant — but you've learned nothing about the real world. Same with models.

Why the topic needs this: the entire fold machinery below is a device to keep "seen" and "unseen" strictly separate — so the score stays honest.


2. Folds: cutting the stack into equal piles

The little subscript number (the tiny in ) is just a label — "pile number one". It carries no maths; it's a name tag.

Figure — K-fold cross-validation

Why "equal-sized"? If one pile were tiny and another huge, the grades wouldn't be comparable — a score from 2 cards is far shakier than from 40. Equal piles make every turn a fair fight.


3. Set language: , , , "disjoint"

The parent note writes things like and . These are just shorthand for combining and removing piles. Let's earn each squiggle.

Figure — K-fold cross-validation

Why the topic needs this: the split "train on all folds but one, validate on the one held out" is and . That one line of set-notation is the whole algorithm.


4. Subscripts and the loop index

Think of as which chapter of the exam you're currently marking. When you hide pile 1; when you hide pile 2; and so on until every pile has had its turn as the hidden test.


5. The model, its parameters , and training

You don't need to know what's inside — for this topic is just a box that came out of training and can now answer questions.

Why theta and not a plain letter? Convention: across machine learning, almost always means "the learned parameters". Using it here connects this note to everything else you'll read.


6. The metric and a "score"

Why the topic needs this: every round produces one score. The whole point of rounds is to get scores we can then combine.


7. Summation — the averaging machine

The final estimate uses . Let's earn it before using it.


8. Spread: the standard error


Prerequisite map

Dataset D of N cards

Cut into K equal folds F1..FK

Set language union minus disjoint

Split each round train Ti validate Vi

Loop index i counts rounds

Training T gives parameters theta

Score each round with metric M

Summation adds the K scores

Average gives CV estimate

Standard error gives reliability

K-fold cross validation

Each box on the left must feel obvious before the box on its right makes sense. When the whole chain feels natural, you're ready for the parent note.


Equipment checklist

Cover the right-hand side and test yourself. Say the answer out loud before revealing.

What does the symbol stand for?
The whole dataset — the full stack of examples.
What does count?
The number of samples (cards) in the dataset.
What is a fold?
One of the equal-sized piles we cut the dataset into.
What does mean, and typical values?
The number of folds; usually 5 or 10.
How many cards are in each fold?
About .
Read in plain words.
Glue piles and into one bigger pile (union).
Read in plain words.
The whole dataset with pile removed.
What does "disjoint" guarantee?
No single card appears in two folds — seen and unseen stay separate.
What is the index doing?
Counting the rounds, from 1 up to .
What is ?
The parameters the model learned in round .
What does the metric produce?
A single grading number for a model on some cards.
Read in words.
Add up the scores from round 1 through round .
Why do we divide the sum by ?
To turn the total into an average across the rounds.
Why square the differences inside SE?
So above- and below-average gaps both count positively and don't cancel.
A large standard error means what?
The folds disagree a lot — the estimate is unreliable / the model is fragile.