How machines learn
Training, Validation, and Test: Three Different Jobs
Understand why learning projects separate fitting, development, and final evaluation, and how entity, time, and reuse affect split validity.
By the end you can
- Explain the distinct roles of training, validation, and test partitions
- Choose split units that prevent identity and temporal contamination
- Recognize validation and test-set wearout from repeated decision making
- Design a split strategy that resembles the intended future use
Visual
The three partitions answer different questions
A split is not clerical housekeeping. It creates separate evidence for fitting, choosing, and making a final claim.
The three roles are not interchangeable, and in some fields that is not left to taste. Medical-device regulators have written it down. In October 2021 the US FDA, Health Canada and the UK's MHRA jointly issued ten guiding principles for good machine learning practice. The eighth requires performance evidence generated “independently of the training data set”. That sentence is the test set's entire job description. It is also the one job the training and validation partitions cannot do — not because they are lower-quality data, but because they have already been spent on decisions.
Training set
What parameter values fit the observed examples?
- Used by the fitting algorithm
- May be revisited across epochs
- Supports training diagnostics
- Does not provide independent performance evidence
Validation set
Which design and hyperparameter choices appear promising?
- Guides model and threshold selection
- Supports error analysis during development
- Can wear out through repeated use
- Should resemble the intended evaluation setting
Test set
How well does the selected procedure perform on untouched evidence?
- Used after major choices are frozen
- Supports the final bounded claim
- Should not guide iterative tuning
- May need replacement after extensive exposure
Key idea
Choose what stays together before choosing percentages
An 80/10/10 ratio says nothing about whether the split is honest. If records from one user, household, patient, machine, document, or video appear across partitions, the model may see highly related evidence during training.
Define the split unit first. The percentage comes later, and should reflect data volume, uncertainty, and the cost of reserving evidence.
This is not a house style. Three national regulators have written it down as a development principle. The fourth of their ten principles is titled “Training Data Sets Are Independent of Test Sets”, and it reads: “Training and test datasets are selected and maintained to be appropriately independent of one another. All potential sources of dependence, including patient, data acquisition, and site factors, are considered and addressed to assure independence.” Note what that does and generic advice does not: it names the axes. Patient, data acquisition, site. That list is the split-unit question. And “all potential sources of dependence” makes finding the rest of the list the developer's obligation rather than the reviewer's.
Two of the most-benchmarked datasets in computer vision did not hold the barrier. In 2020 Björn Barz and Joachim Denzler compared every test image in CIFAR-10 and CIFAR-100 against the training set. They found that “3.3% and 10% of the images from the test sets of these datasets have duplicates in the training set” — CIFAR-10 and CIFAR-100 respectively. So they rebuilt the test sets with fresh images sampled from the same domain, and named the result ciFAIR. Popular architectures re-run on it showed “a significant drop in classification accuracy of between 9% and 14% relative to the original performance on the duplicate-free test set”.
Read the unit before reacting to the number. That figure is relative. In absolute terms the same paper reports that “the error rate increases by 0.41 percent points on CIFAR-10 and by 2.73 percent points on CIFAR-100”. The authors' own verdict is the reassuring one. They write that “the relative ranking of the models did not change considerably”. So, they conclude, “the research efforts of the community do not seem to have overfitted to the presence of duplicates in the test set yet”. A decade of leaderboards was not wrong. The split unit had gone unchecked.
A split is defined by independence and deployment logic, not by a fashionable ratio.
The test set should resemble the claim you plan to make
If deployment predicts future weeks, a chronological test is often more informative than a random historical split. If the system serves new stores, hold out stores. If it makes repeated predictions for known users, an event-level split may be appropriate — but that is a different claim from performance on new users.
The most thoroughly documented case of a model that fit history beautifully and then failed forward is Google Flu Trends. It was built to predict CDC influenza-like-illness reports by matching 50 million candidate search terms to 1,152 data points. That is an enormous space of candidate predictors searched against a very short outcome series. Retrospectively it looked excellent. Prospectively it did not. David Lazer and three colleagues reported in Science in 2014 that “GFT also missed by a very large margin in the 2011–2012 flu season and has missed high for 100 out of 108 weeks starting with August 2011”. The counted window runs from 21 August 2011 to 1 September 2013. The 2011–2012 season was overshot by more than 50%.
The comparison that settles the matter is the baseline, not the error. Over the out-of-sample period the mean absolute error was 0.486 for GFT against 0.311 for a simple lagged-CDC model. A system trained on 50 million candidate terms was beaten forward in time by the outcome variable's own recent history. No random split of the historical record would have shown that, because a random split lets the model borrow from weeks on both sides of the one it is predicting.
No split is universally correct. Write the deployment question, then create partitions that test that question.
Case
CASP14: an exam whose answers did not yet exist anywhere
Structural biology enforces this by holding its exam outside the field. The Critical Assessment of protein Structure Prediction runs every two years, and it is not run by the entrants. Its organisers and assessors describe the mechanism in their own words: “CASP identifies a set of modeling targets—proteins for which the experimental structure is about to be solved or is solved but still not public—and provides the corresponding amino acid sequences to the modeling community.” The structures used have been solved experimentally but “not been deposited in the PDB or publicly disclosed”. Entrants predict before the answer exists anywhere they could look it up.
The scale is what makes "the answer did not exist anywhere" a countable claim rather than a flourish. In CASP14, 97 research groups from 19 countries tested 215 modeling methods and submitted over 67,000 predictions. The organisers released 52 experimental structures as 68 tertiary targets, reorganised into 96 evaluation units. DeepMind entered AlphaFold2 — group 427 — assessed between May and July 2020. The assessors record that its models were competitive with experimental accuracy for at least two-thirds of targets, and that for only four targets did another group obtain a higher GDT_TS. DeepMind's own report in Nature in 2021 states the same result in ångströms: a median backbone accuracy of 0.96 Å r.m.s.d.95 across the CASP domains, whereas the next best performing method managed 2.8 Å. A carbon atom is about 1.4 Å wide.
The claim carries for two reasons that a benchmark score does not usually get to combine. The evidence was withheld until after the predictions were submitted. And the people withholding it were not the people who benefited from the result. No retrospective split over already-published structures could have supported it.
Example
Common split strategies and what they test
Different deployment settings require different barriers between partitions. The barrier you choose determines the claim you are allowed to make.
The site barrier has been measured. A pneumonia-screening convolutional network trained on chest radiographs from Mount Sinai and the NIH scored an internal test AUC of 0.931 (95% CI 0.927–0.936). On an external test set from Indiana the same model scored 0.815 (95% CI 0.745–0.885, P = 0.001), and it performed worse externally in 3 of 5 natural comparisons. John Zech and five colleagues published that in PLOS Medicine in 2018.
Then they asked why, and the answer is the reason site holdouts exist at all: “CNNs were able to directly detect hospital system of a radiograph for 99.95% NIH (22,050/22,062) and 99.98% MSH (8,386/8,388) radiographs.” The network could name the hospital from the image almost perfectly. A random patient-level split leaves that signal on both sides of the barrier. There it is free to substitute for pneumonia whenever the two happen to correlate — which they do, because base rates differ between hospitals.
- Random example split: appropriate when examples are close to independent and future cases resemble the historical mixture.
- Group split: keeps all records from one user, device, household, site, or case together — the patient factor Guiding Principle 4 names first.
- Time split: trains on earlier periods and evaluates on later periods to test temporal transfer; it is the barrier Google Flu Trends was eventually judged against, and failed.
- Geographic or site holdout: measures transfer to locations not represented in training — the 0.931 to 0.815 AUC gap Zech and colleagues measured between their internal and external test sets.
- Hybrid split: combines time and group constraints, such as future patients from hospitals absent during training.
Repeated peeking turns evidence into a design input
A validation set is expected to influence development. A test set is intended to provide a final check after choices are made. If the team keeps redesigning the model after every test result, the test becomes another validation set.
Large organizations may use staged holdouts, private challenge sets, temporal refreshes, or an evaluation service that returns limited information. The purpose is not secrecy for its own sake. It is to preserve evidence that has not shaped the system.
The measured damage is smaller than the fear, which is worth knowing before rebuilding a pipeline over it. A 2019 meta-analysis went through “data from 120 machine learning competitions on the popular Kaggle platform”. Its seven authors used the platform's own design: a public leaderboard scored throughout the contest, and a private test set scored once at the end. Despite up to 35,000 submissions per competition, the classification competitions “show little to no signs of overfitting”, with potential effect sizes “typically small (e.g., less than 1% classification accuracy)”. The exceptions teach the actual lesson. The outlier competitions “have pathologies such as non-i.i.d. data splits or (effectively) small test sets”, two of them with private test sets “of size 209 and 100”. Repeated peeking bites hardest where the holdout was too small, or too correlated with the training data, to begin with.
The second measurement is larger and stranger. Benjamin Recht and three colleagues did not analyse leaderboards. In 2019 they rebuilt the CIFAR-10 and ImageNet test sets by re-running the original collection processes, then re-scored the published models. Accuracy fell by 3–15% on CIFAR-10 and 11–14% on ImageNet — after years in which those same test sets had been the target everyone tuned against. The obvious explanation turns out to be the wrong one. They write: “Our results suggest that the accuracy drops are not caused by adaptivity, but by the models' inability to generalize to slightly "harder" images than those found in the original test sets.”
The story does not end there, and the ending is the part worth carrying. A separate group remeasured the selection frequencies used to assemble the replacement images. Once statistical bias in the replication is corrected, they reported in 2020, only about 3.6% of the original 11.7% ImageNet drop remains unaccounted for. Most of the first careful measurement of a holdout effect was an artefact of how the replacement set had been built. Rebuilding a test set is itself a sampling design. It can go wrong in exactly the ways the original did.
Analogy
An analogy: practice papers and a sealed final exam
Students use practice papers to choose study strategies. The final exam stays sealed until preparation ends. If teachers reveal final questions after every practice round, students can adapt to that exam rather than the subject.
Validation and test data play similar roles. CASP is the rare case where the analogy is literal rather than illustrative: the questions are set by people who are not sitting the exam, and the answers are not public anywhere when the papers are submitted. Most projects cannot buy that. No dataset stays sealed for long. They drift over time, observations arrive grouped, and re-evaluation continues after deployment.
Steps
Design the partition in five deliberate moves
Write the split policy before extensive exploration whenever possible. The five moves below are Guiding Principle 4 turned into a checklist. Name the claim, name the sources of dependence, then decide in advance who is allowed to look at the answer and when.
1. State the claim
New events, new entities, future time, new sites, or a specific mixture?
2. Choose the barrier
Select the identity, time, location, or case boundary that prevents contamination.
3. Check distributions
Compare label prevalence, feature ranges, and important slices across partitions.
4. Remove relatives
Find exact duplicates, near-duplicates, overlapping windows, and shared source artifacts.
5. Set access rules
Document who may view test results, when, and what triggers a fresh holdout.
When data is scarce, separation still matters
Small datasets make fixed holdouts noisy. Using all the data for both fitting and evaluation does not solve the problem. Cross-validation, grouped resampling, repeated splits, or carefully designed temporal backtests can use data more efficiently.
The Kaggle meta-analysis shows the danger from the other side. Across 120 competitions the overfitting effect was typically under 1% accuracy. The competitions that did misbehave were the ones whose private test sets held 209 and 100 examples. A tiny holdout mostly supplies noise, and noise is what an adaptive process learns to exploit first.
Later evaluation paths will cover these methods in depth. The beginner principle is simple: every performance claim needs examples that did not influence the fitted parameters or the choices being judged.
Example
A suspiciously perfect test result
When a test metric looks implausibly high, investigate the split before celebrating. The checks below were skipped at the scale of an entire literature, and the resulting review is the strongest available argument for running them.
A systematic review searched 2,212 studies of machine learning applied to COVID-19 detection and prognosis from chest radiographs and CT scans. It kept 415 after screening and 61 after quality review. It found none of the models of potential clinical use. Michael Roberts and the AIX-COVNET collaboration at Cambridge published it in Nature Machine Intelligence in 2021.
A recurring cause was the public 'Frankenstein' dataset — a dataset assembled from other datasets and re-released under a new name, so that a team believing it had trained on one corpus and tested on another had done neither. The review states the mechanism plainly: “This repackaging of datasets, although pragmatic, inevitably leads to problems with algorithms being trained and tested on identical or overlapping datasets whilst believing them to be from distinct sources.” Its remedy is this lesson's split-unit rule in a reviewer's words. Authors should “state how they ensured that images from the same patient were not included in the different dataset partitions, such as describing patient-level splits”.
How deep the source signal ran is measurable. Blacking out the central lung region of the same public X-ray images — deleting the anatomy the models were supposed to be reading — still left the source datasets distinguishable, the lowest ROC-AUC being 0.92. Maguolo and Nanni ran that test at the University of Padova in 2021. Whatever those classifiers had learned, it survived the removal of the lungs.
- Search for duplicates and near-duplicates across partitions — the check that turned up 3.3% and 10% contamination in the CIFAR-10 and CIFAR-100 test sets.
- Check whether multiple rows from the same entity or source file were separated, and whether the 'new' dataset is a repackaging of one already in your training data.
- Review features for timestamps, post-outcome fields, and identifiers — including the site artefacts that let a network name the hospital system for 99.95% of NIH radiographs.
- Confirm preprocessing was fitted only on training data.
- Recreate the split using a future, group, or site holdout and compare the drop.
Key takeaways
- Training, validation, and test partitions support fitting, development choices, and final evaluation respectively. Guiding Principle 8 of the October 2021 FDA / Health Canada / MHRA practice asks for evidence generated “independently of the training data set”.
- An honest split begins with the deployment claim and the unit that must remain separated. Patient, data acquisition, and site are the dependence axes Guiding Principle 4 names by hand.
- Random, grouped, temporal, site-based, and hybrid splits test different forms of generalization. A site holdout took Zech and colleagues' pneumonia model from 0.931 to 0.815 AUC, because the network could identify the hospital system in 99.95% of NIH radiographs.
- Repeated peeking wears validation and test sets out, but every careful measurement has found the effect smaller than feared: 120 Kaggle competitions showed “little to no signs of overfitting”, and only about 3.6% of the 11.7% ImageNet replication drop survives correction for statistical bias.
- Duplicates, overlapping windows, shared entities, repackaged public datasets, and all-data preprocessing can contaminate a split. 3.3% of CIFAR-10 test images had duplicates in training, and Roberts and the AIX-COVNET collaboration found none of 61 quality-screened COVID-19 models clinically usable.
- When data is scarce, resampling can improve efficiency, but evaluation must still be separated from the choices it judges. The Kaggle competitions that did overfit were the ones with private test sets of size 209 and 100.