Ground Truth.
AI, checked against the source.

Learn · Beginner

Cross-validation: how you find out whether a model learned anything or just memorised the answers

Cross-validation is the practice of measuring a model only on examples it has never been trained on, and it exists because a model's score on its own training data is close to meaningless. Any sufficiently flexible model can memorise the answers to the questions it was shown, and memorisation produces a perfect score while teaching the model nothing about a question it has not seen. The entire apparatus of holdout sets, k-fold splits, and untouched test sets is machinery for one purpose: making sure the number you report is a number about the future, not about the past.

Start with the simplest version. Take your dataset, set aside a random slice, commonly 20%, and do not let the model see it during training. Train on the rest. Then score on the slice you held back. This is a holdout set, and it works because those examples had no opportunity to be memorised. If the model does well on them, it has captured something that transfers.

The analogy people reach for is a practice exam, and it is a good one as long as you follow it all the way through. A student who studies a practice test until they can recite it has learned the practice test. Their score on it says nothing. Give them a fresh exam covering the same material and now you learn something. The catch, and the reason this topic is subtler than it looks, is what happens when the student takes many fresh exams and you keep tuning their study plan based on the results. After twenty rounds, the study plan has been fitted to those twenty exams, and they have stopped being fresh.

This is why serious practice uses three sets, not two. Training data teaches the model. Validation data guides your choices: which architecture, which learning rate, when to stop training. Test data is looked at once, at the very end, and never used to make a decision. The reason for the third set is exactly the practice-exam problem. Every time you compare two models on the validation set and keep the winner, you leak a little information from that set into your model, and the validation score drifts optimistic. Gavin Cawley and Nicola Talbot documented this carefully in On Over-fitting in Model Selection, showing that tuning against a validation set produces a selection bias large enough to reverse published comparisons between methods.

When data is scarce, a single holdout split is wasteful and noisy. Hold back 20% of a thousand examples and your evaluation rests on two hundred points, so the score swings depending on which two hundred you happened to draw. K-fold cross-validation fixes this. Split the data into k equal parts, commonly five or ten. Train k times, each time holding out a different part and training on the other k-1. Average the k scores. Every example gets used for training in most rounds and for testing in exactly one, and the average is far more stable than any single split. Ron Kohavi's 1995 study compared these schemes empirically and settled on stratified ten-fold cross-validation as a sound default, a recommendation that has held up for three decades.

Two failure modes are worth naming, because both are common and both invalidate results silently.

The first is leakage: information from the held-out data reaching the model through a side channel. Normalizing your features using statistics computed over the full dataset before splitting is leakage. So is imputing missing values globally, or selecting which features to keep by looking at all the data. In each case the model has learned something about the test set without ever being trained on it. The rule is that every step which learns from data must happen inside the training fold.

The second is splitting randomly when your data is not random. Time series data must be split by time, because predicting the past from the future is not a task anyone has. Medical data with multiple records per patient must be split by patient, or the model sees the same person on both sides. Data with duplicates or near-duplicates must be deduplicated first, or copies of the same example land in both training and test sets. A random split assumes examples are independent, and real datasets frequently are not.

For large language models the mechanics change but the principle does not. Nobody runs ten-fold cross-validation on a trillion-token corpus. Instead there is a held-out slice for measuring perplexity, and public benchmarks stand in for the test set. That substitution is where the modern version of the problem lives, because a public benchmark is only a valid test set if the model has genuinely never seen it, and models trained on scraped internet text routinely have. That is benchmark contamination, and it is the same failure as testing on your training data, arrived at by accident at enormous scale. The whole field's evaluation practice, and every argument about whether a reported score is real, rests on the discipline this lesson describes: hold something back, and do not peek.

Key papers
A Study of Cross-Validation and Bootstrap for Accuracy Estimation and Model Selection (Kohavi, 1995)
On Over-fitting in Model Selection and Subsequent Selection Bias in Performance Evaluation (Cawley and Talbot, 2010)
Random Search for Hyper-Parameter Optimization (Bergstra and Bengio, 2012)

Key questions

Why can't you evaluate a model on the data it was trained on?

Because a model can score perfectly by memorising the training examples without learning anything that generalizes, so a training score measures recall of what it saw, not ability on what it has not.

What is the difference between a validation set and a test set?

The validation set is what you look at repeatedly while choosing settings and comparing models, and the test set is looked at once at the very end, because anything you optimize against stops being an honest measurement.

When should you use k-fold cross-validation instead of a single split?

When your dataset is small enough that a single holdout split would be noisy, since k-fold reuses every example for both training and testing across different rounds and averages the results.
Cite this

APA

Ground Truth. (2026, September 2). Cross-validation: how you find out whether a model learned anything or just memorised the answers. Ground Truth. https://groundtruth.day/learn/cross-validation-and-holdout-sets.html

BibTeX

@misc{groundtruth:cross-validation-and-holdout-sets,
  title  = {Cross-validation: how you find out whether a model learned anything or just memorised the answers},
  author = {{Ground Truth}},
  year   = {2026},
  month  = {sep},
  url    = {https://groundtruth.day/learn/cross-validation-and-holdout-sets.html}
}

Topics: evaluation · methodology · overfitting · fundamentals · benchmarks