5.6.5 · D1Machine Learning (Aerospace Applications)

Foundations — Cross-validation — k-fold

2,313 words11 min readBack to topic

Before you can read the parent note Cross-validation — k-fold, you need to earn every symbol it uses. This page introduces them one at a time, each with a plain-words meaning, a picture, and the reason the topic needs it. Nothing here assumes you've met the notation before.


1. A dataset , its size , and its samples

Let's decode every piece of that line, left to right.

  • The curly braces mean "a collection of things" — here, a collection of rows.
  • Each row is a pair written in round brackets : an input glued to its correct answer.
  • The little number below, the subscript , is just a row label — "the -th row". So is the input of row 3.
  • The three dots mean "and so on in the same pattern", counting up to the last row .

In the parent's aerospace example, and one row is one flight record: holds the 50 sensor readings (temperature, vibration, pressure), and is a single bit — did the engine fail within 100 hours () or not ()?

Figure — Cross-validation — k-fold

2. The fold count and fold sizes

Since we already met , keep the two straight — they play very different roles:

Which is bigger, or ?
— you have many rows () split into a few folds ().
If and , how big is each fold?
rows.

The picture below shows the clean case where the chop divides evenly.

Figure — Cross-validation — k-fold

3. Folds and the "carve out" operations , ,

Before we can write the fold equation, we must name the folds themselves.

The parent then writes . Three new symbols hide in there. Each is a way of talking about groups of rows.

Now the parent's line just says: "gluing all the folds back together rebuilds the whole dataset — nothing lost, nothing added."

And for (read " not equal to ") says: "two different folds share no rows." That is the disjoint property, and it is why a row can never be both trained-on and tested-on in the same round.

Figure — Cross-validation — k-fold

The set-minus symbol powers the parent's training-set definition: Read aloud: "the training set for round is the whole dataset with fold removed." The superscript in brackets is just a round label — "the version used in round ", not a power. (Brackets around the top number are the standard way to signal "this is a label, don't multiply.")


4. The learning algorithm and the trained model

Think of as an empty brain and the parentheses as "feed this data into the brain". Out pops a specific fitted model . Because each round removes a different fold, each is a slightly different model.

Why the subscript on ?
Because there are different trained models, one per round — .

5. The metric function and the score

What does the metric use each of its two inputs for? The first, , makes the guesses; the second, , supplies both the inputs to guess from and the hidden true answers to compare against. The parent uses two common metrics:

  • Accuracy — fraction of guesses that are correct. Simple, but a liar when one class is rare (guessing "no failure" always gives 95% on a 5%-failure dataset).
  • F1 score — a balanced number that rewards catching the rare cases and not crying wolf. Preferred when failures are rare.

You don't need the F1 formula yet — just know is one honest grade per round, and higher is better here.


6. Summation , mean, and the CV score

Here is the symbol that scares the most beginners. It is friendly once unpacked.

Now the headline formula falls out for free:

Why average, not just pick one? One round could get an easy test fold and score high by luck. Averaging rounds cancels good luck against bad luck, giving a steadier estimate of true performance.


7. Spread: the standard deviation

The average alone hides consistency. The parent also reports a spread.

Decode it piece by piece, from inside out:

  1. — how far one grade sits from the average (a "miss").
  2. — square it, so negative misses and positive misses both count as positive distance.
  3. — add up all the squared misses.
  4. — divide (nearly the average miss; using not is a standard small-sample correction).
  5. — take the square root to undo the squaring, returning to the original units.

How these pieces feed the topic

Dataset D with n samples

Split into k folds Di

Disjoint folds no shared rows

Train set D minus Di

Test set is Di

Algorithm A makes model Mi

Score i by a metric

Sum then divide gives CV score

Standard deviation gives spread

k-fold cross-validation estimate

Everything on this page is a prerequisite arrow pointing at the same destination: a single trustworthy number (plus a wobble) for how well a model will do on data it has not seen.


Where to go next


Equipment checklist

You are ready for the parent note when you can answer each of these without peeking.

What does stand for?
Row of the data — inputs paired with the correct answer .
What is the difference between and ?
is the number of rows; is the number of folds we chop them into.
When is not divisible by , how big is each fold?
Either or rows — differing by at most one sample.
What does denote?
The -th fold — the bundle of rows in piece number .
What does tell you?
Different folds share no rows — they are disjoint, so no row is both trained-on and tested-on.
What does mean?
The whole dataset with fold removed — i.e. the training set for round .
What is the difference between and ?
is the empty recipe; is the model after has learned from round- training data.
What kind of object is ?
A function taking a model and a dataset and returning one number (a scalar score).
What does compute?
The sum of all round grades: .
How do you get from that sum?
Divide by — it is the average of the grades.
What does a large warn you about?
The model's performance swings a lot depending on which data it sees — it is not consistent.
Recall Self-test: rebuild the whole pipeline from memory

Say the five steps out loud: (1) split into disjoint folds; (2) for each fold, train on and test on ; (3) score each round with a metric; (4) average the scores to get ; (5) take the standard deviation for the spread. If you can do all five, open the parent note.