Training, Validation, and Test Data Sets — Definition & Example
Training, validation, and test data sets are three non-overlapping parts of one data set. You use the training set to fit a model, the validation set to choose between model versions, and the test set once at the end to estimate how well the final model works on new data.
Given a data set of observations, a train-validation-test split is a partition into pairwise disjoint subsets, usually made by random assignment. Model parameters are estimated only from . Hyperparameters and model choice are selected by performance on . The error on , computed once for the selected model, serves as an estimate of its generalization error.
Worked Example
Problem: You have 2,000 labeled customer emails and want a model that flags spam. You split the data 70% / 15% / 15% into training, validation, and test sets. You train three candidate models. Their validation accuracies are Model A: 82%, Model B: 88%, Model C: 85%. You then run the chosen model on the test set, and it classifies 255 of the test emails correctly. What accuracy should you report?
Step 1: Find the size of each subset. Every email goes into exactly one of the three sets.
Step 2: Pick the model with the highest validation accuracy. Model B wins with 88%. The validation set has now been used to make a choice, so 88% is likely an optimistic estimate.
Step 3: Evaluate Model B once on the 300 test emails, which played no part in training or selection.
Answer: Report a test accuracy of 85% for Model B. The 88% validation figure is biased upward because it was used to pick the winner.
Why It Matters
In machine learning and data science courses, this split separates a model that has memorized its data from one that generalizes. The same logic appears in statistics as out-of-sample validation. Picking the best of many models and reporting its in-sample score leads to inflated claims, much like running many hypothesis tests and reporting only the significant one.
Common Mistakes
Mistake: Checking test-set performance repeatedly and adjusting the model each time, or tuning the model on the test set.
Correction: Each look at the test set leaks information into your choices, so its error stops being an honest estimate. Do all tuning on the validation set and touch the test set only once, at the end.
