Machine learning model evaluation
Model evaluation starts with a deliberate division of data into training, validation, and test sets.
Try it: K-Fold Cross-Validation and Model Selection
How hold-out and k-fold cross-validation choose among candidate models: each fold takes a turn as the validation set, the fold errors are averaged, the lowest average picks the model, and only then is the untouched test set used once — while tuning on the test set would report an optimistic number.
How it works
- Set 10 test points aside; they take no part in any choice.
- Optionally shuffle the 20 development points (seeded), then cut them into k folds (hold-out: one chunk validates, the rest trains).
- For every round, train each candidate polynomial on the other folds and measure its validation MSE on the held-out fold.
- Average each candidate's fold errors (with repeated shuffling: average the p run scores; p × k fits per candidate).
- Select the candidate with the lowest average, retrain it on all development points, and evaluate it once on the test set.
- For contrast, show which candidate the test set itself would have picked — that figure is leaked and optimistic.
Default run (12 steps): 20 development points (sorted by x as they arrived) and 10 test points set aside. Candidates: polynomial degree 0, 1, 2, 3, 4, 5, 6. Plan: 5-fold cross-validation, shuffled with seed 1 → 5 fits per candidate (p × k = 1 × 5), 35 in total. … 5-fold cross-validation picks degree 3 (score 0.0768); its honest test MSE is 0.0889. Picking by test error would report degree 4 at 0.0868 — a leaked, optimistic figure.
Simplified: One fixed toy dataset (20 development + 10 test points from sin(2πx) with noise) and polynomial least squares of degree 0–6 as the candidate models. Shuffling uses a seeded mulberry32 Fisher–Yates; folds are contiguous chunks like scikit-learn's KFold. Hold-out uses the first of k chunks as the validation set.
Loading the simulation…
Evaluation Starts with Data Roles
Model evaluation begins before you calculate a score. First, decide how the available data will be divided and what role each part will play. The central division is into training, validation, and test sets. Training data supports model training, validation data supports the evaluation process used while working with the model, and test data provides the final evaluation role. Keeping these roles distinct makes the evaluation plan deliberate rather than accidental.
A Worked Data Division
Assigning roles before scoring
Imagine a dataset that must be organized for a model evaluation process. How can its records be assigned distinct roles?
- 1Start with the available data
Treat the complete collection of available records as the source from which the evaluation roles will be created.
- 2Assign training data
Place one portion in the training role so it is available for model training.
- 3Assign validation data
Place another portion in the validation role for the evaluation process.
- 4Reserve test data
Keep a separate portion in the test role for the final evaluation.
The important result is not a particular numeric split. It is a deliberate separation of roles before calculating a score.
The Single Hold-Out Split
Simple hold-out validation is the basic splitting recipe. Instead of creating several fold-based arrangements, it makes one division: one portion is used for training and one portion is held out for validation. This can be enough in some situations. Its defining feature is that the training and validation arrangement is a single split rather than a collection of fold-based arrangements.
A team might use simple hold-out validation when a single training portion and a single held-out validation portion fit the situation. The method is recognized by its one training-validation split.
K-Fold Rotation
K-fold validation changes the arrangement from one split to multiple folds. The dataset is organized into several folds, and the method forms multiple training and validation arrangements from those folds. In each arrangement, one fold serves as the validation portion while the remaining folds serve as the training portion. The validation role therefore rotates across the folds.
Reading a three-fold arrangement
Suppose a dataset has three folds named A, B, and C. What does the fold rotation represent?
- 1First arrangement
Fold A is the validation portion, while folds B and C form the training portion.
- 2Second arrangement
Fold B becomes the validation portion, while folds A and C form the training portion.
- 3Third arrangement
Fold C becomes the validation portion, while folds A and B form the training portion.
Each fold takes a turn in the validation role, while the other folds take the training role.
Shuffling and Repeating Folds
Iterated K-fold validation with shuffling extends K-fold validation in two ways. It adds shuffling to the dataset arrangement, and it repeats the K-fold approach. Repetition with different fold assignments creates additional fold-based training and validation arrangements. The defining distinction is therefore not merely that folds are used, but that shuffling and repetition are added to the K-fold process.
| Recipe | Data arrangement | Defining feature | When the source suggests considering it |
|---|---|---|---|
| Simple hold-out validation | One training portion and one held-out validation portion | A single split | When a single split is enough |
| K-fold validation | Several fold-based training and validation arrangements | Validation rotates across folds | When a single split is not the preferred arrangement |
| Iterated K-fold validation with shuffling | Repeated fold-based arrangements after shuffling | Shuffling and repetition extend K-fold validation | When little data is available and a more advanced splitting method is useful |
The table compares the structural distinctions described in the source material.
Choosing with Limited Data
The source material gives a practical starting point: a single split may be enough in some situations, but more advanced splitting methods can be useful when little data is available. Use the method names to describe the arrangement you need. Choose simple hold-out validation when one training-validation split is appropriate. Choose K-fold validation when you want several fold-based training and validation arrangements. Choose iterated K-fold validation with shuffling when you want K-fold validation extended by shuffling and repetition.
Common Recognition Errors
Common mistake Treating model evaluation as a scoring step only.
What it looks likeA learner begins by calculating a score without first deciding which records belong to training, validation, and test roles.
Why it failsThe source defines the division of available data as the starting point of evaluation.
Do this insteadDescribe the data roles and splitting recipe before discussing the score.
Common mistake Calling every split K-fold validation.
What it looks likeA single training portion and a single held-out validation portion is labeled K-fold validation.
Why it failsSimple hold-out validation is the basic single-split recipe, while K-fold validation uses multiple folds to form several arrangements.
Do this insteadUse simple hold-out for one split and K-fold for multiple fold-based arrangements.
Common mistake Forgetting what iterated K-fold adds.
What it looks likeA repeated method is described as ordinary K-fold validation even though shuffling is performed between repetitions.
Why it failsIterated K-fold validation with shuffling specifically adds shuffling and repetition to K-fold validation.
Do this insteadMention both additions when identifying the iterated method.
Common mistake Assuming limited data automatically dictates one named recipe.
What it looks likeA learner claims that every limited dataset must use iterated K-fold validation.
Why it failsThe source says advanced methods can be useful when little data is available, while also noting that a single split may be enough in some situations.
Do this insteadConsider whether a single split is enough, then distinguish K-fold from iterated K-fold according to the arrangement required.
Check Your Choice
A dataset is limited. You first consider one training portion and one held-out validation portion. Then you consider several fold-based arrangements. Finally, you consider shuffling the dataset and repeating the fold-based process. Name the three evaluation recipes in the order described and state the defining change from one recipe to the next.
Hints
- The first recipe is the basic splitting recipe.
- The second recipe uses multiple folds.
- The third recipe adds shuffling and repetition to the second recipe.
What do you think happens?
Which description identifies iterated K-fold validation with shuffling?
Reveal answer
Shuffling the dataset and repeating the K-fold approach
The source describes iterated K-fold validation with shuffling as K-fold validation extended by shuffling and repetition.
Key Takeaways
- 1Model evaluation begins by deliberately dividing available data into training, validation, and test roles.
- 2Simple hold-out validation uses one training-validation split.
- 3K-fold validation uses multiple folds to form several training and validation arrangements, with the validation role rotating across folds.
- 4Iterated K-fold validation with shuffling adds shuffling and repetition to the K-fold approach.
- 5When data is limited, a single split may be enough in some situations, while more advanced splitting methods can also be useful.
At a glance
- Evaluation starts with a deliberate data division, not with score calculation.
- Training, validation, and test sets have separate roles in the evaluation process.
- Simple hold-out uses one split; K-fold uses several fold-based arrangements.
- Iterated K-fold validation with shuffling adds shuffling and repetition to K-fold validation.
- For limited data, consider whether a single split is enough or whether an advanced fold-based method is useful.