Citation and evidence

Validation

10 min full readUpdated 13 references

This article's verification

Report a problem with this article

Edit article
More

Use this article

Raw MarkdownExplore connections

Improve this page

Revision historyDiscuss this article

Topics

Machine Learning

Cite this article

See also: Machine learning terms

Validation in machine learning uses examples held out during training to compare candidate models, tune hyperparameters, or decide when to stop training. A fixed validation set can serve this purpose, or different parts of the development data can take turns as validation folds in cross-validation. Once a validation score has guided a choice, reporting that same score as the performance of the chosen model can give an optimistic estimate. A separate test set provides a final evaluation independent of those choices.[1][2][3]

What is validation in machine learning?

In supervised learning, a model predicts the labels of held-out examples. Comparing predictions with known answers tells the developer how well the current settings work on those examples. Two decision trees might both fit the training set closely. Their validation errors can help decide which tree depth to use. In a neural network, the choice might instead be how long to train.[1][4][5]

Why is a separate validation set needed?

A model can memorize training examples and then fail on new ones. Scoring it on examples excluded from fitting helps detect overfitting. A second problem arises if a developer repeatedly changes the model in response to test scores. The test examples now influence the choice of model even though the training algorithm never receives their labels.[1][2]

The validation set allows the developer to compare learning rates, regularization strengths, or feature sets while reserving the test set. The usefulness of either score also depends on which examples were held out. Duplicate training records in the test set, for example, can make a memorizing model look as though it generalizes.[1][3]

How do validation, training, and test sets differ?

SetRoleWhen used
Training setFits model parameters such as weights or coefficientsDuring each training run
Validation setGuides hyperparameter tuning, model selection, or early stoppingBetween training runs or epochs
Test setEstimates generalization to the population or period it representsAfter the model and the evaluation choices are fixed

Expanded article table

These roles describe how the results are used. If the test score prompts another round of tuning, an independent evaluation of the revised model requires fresh data or an outer evaluation set kept apart from those decisions.[1][2][6]

What are typical train, validation, and test split ratios?

There is no universal ratio. Google's machine learning course illustrates a 70/15/15 split and explicitly leaves the percentages open. With 1,000 examples, that allocation gives 700 for training and 150 each for validation and testing. With a million independent examples, even a 1% hold-out contains 10,000 examples. Its suitability depends on which cases it contains and the metric being estimated.[1][3]

For classification, a small minority class can be nearly absent from a validation fold. Binary ROC AUC, for example, requires examples of both classes. Stratification can keep the class proportions close to those of the original dataset.[3]

What is hold-out validation?

Hold-out validation sets aside a single validation set. After each training run, the developer measures validation loss or another metric on those examples. Each candidate needs only one fit for that split. With a small dataset, a different choice of held-out examples can give a noticeably different score.[1][3][7]

A hold-out should reflect what will be new when the model is used. If the goal is to predict for new people, all records from each person belong on the same side of a split. In a study of smartphone activity recordings, Saeb and colleagues showed that randomly splitting individual records could underestimate the error on new participants. Scikit-learn's GroupKFold holds out whole groups in each round.[3][8]

For a forecast made at a particular date, training on later observations uses information unavailable at that date. A chronological evaluation trains on earlier records and scores predictions on the next period. Scikit-learn's TimeSeriesSplit repeats this procedure as the training window grows. In a study of forecasting methods, Cerqueira and colleagues found that repeated chronological hold-outs gave the most accurate error estimates for the non-stationary series they tested.[3][9]

What is k-fold cross-validation?

In k-fold cross-validation, the development data are divided into k roughly equal folds. Each example belongs to one fold. The model is trained k times, with a different fold held out each time and the other k minus one folds used for fitting. The k held-out scores can then be averaged. Any separate final test set stays outside these rounds.[3]

Five and ten are common choices for k. Ten folds require ten fits per candidate and each fit uses about 90% of the data. Five folds require five fits and use about 80% per fit. More folds do not guarantee a more precise score. In a 1995 study of C4.5 decision trees and naive Bayes classifiers, Ron Kohavi found that stratified ten-fold cross-validation worked well for model selection on datasets like those in his experiments.[3][7]

What is stratified k-fold?

For classification, stratified k-fold approximately preserves the proportion of each class in each fold. This helps avoid missing classes when the sample permits it. If a class occurs only three times, five disjoint validation folds cannot all contain an example. Keeping proportions similar also makes folds more alike, so a small spread in their scores can conceal uncertainty about performance on rare cases.[3]

What is leave-one-out cross-validation?

Leave-one-out cross-validation, often written as LOOCV, is the case where k equals the number of examples. Each example in turn is held out, and the rest form the training data. One averages the resulting per-example losses, such as an indicator of a wrong prediction. For n examples, a direct implementation fits n models. Their training sets overlap heavily, and the resulting estimate can still have high variance.[3][7]

How does the validation set drive early stopping?

During training, loss on the training set can keep falling even as validation loss starts to rise. Early stopping uses performance on held-out examples to choose a training duration. It acts as a form of regularization by limiting the number of updates the model receives.[5][10]

The stopping rule and the choice of weights are separate decisions. In Keras, the EarlyStopping callback monitors validation loss by default at the end of each epoch. Its patience argument controls how many epochs without sufficient improvement are allowed, and min_delta sets the minimum change that counts. By default, Keras keeps the final weights. Setting restore_best_weights=True restores the weights from the best monitored epoch.[5]

How is the validation set used for hyperparameter tuning?

A typical sweep trains several candidate configurations on the training set, scores each on the validation set, and picks a configuration using the chosen metric. Grid search tries all combinations in a specified grid. Random search samples candidate settings. Bayesian optimization uses the results of earlier trials to choose which settings to try next. Each approach can use held-out or cross-validated scores.[2][4][11]

Can a model overfit to the validation set?

Yes. Even equally capable models can get different scores on a finite sample. Selecting the highest-scoring candidate favors those that happened to do well on that sample. Cawley and Talbot showed that this selection bias can be comparable in size to differences between learning algorithms. Ordinary k-fold cross-validation can also produce this bias if the best mean score from a search is reported as the final estimate.[2][6]

Nested cross-validation evaluates the whole selection procedure. In each outer round, one fold is reserved for testing. On the remaining data, an inner cross-validation selects the hyperparameters. The selected configuration is refitted on the outer training data and scored on the reserved fold. Averaging those outer scores estimates how well the tuning-and-fitting procedure performs on new examples. With grouped or chronological data, the split rules must reflect the prediction task at both levels.[2][3][6][8][9]

Which metrics are used to evaluate the validation set?

The metric used for validation depends on the task. For example, when missed positives are costly, recall measures the fraction of actual positives detected. A model can achieve high accuracy on a dataset with very few positives simply by predicting the majority class.[4][12]

MetricWhat it measures
AccuracyFraction of examples classified correctly
Precision and recallFraction of predicted positives that are correct, and fraction of actual positives detected
F1 scoreHarmonic mean of precision and recall
ROC AUCAbility of a binary classifier's scores to rank positive examples above negatives across decision thresholds
Mean squared errorAverage squared prediction error in regression, giving larger errors more weight
Mean absolute errorAverage absolute prediction error, in the units of the target
Cross-entropy lossFor a single true class per example, the average negative log probability assigned to that class

Expanded article table

Scikit-learn's scoring guide gives the definitions of these metrics. Choosing the metric before comparing candidates also defines what a higher or lower validation score means for the application.[4][12]

What does a standard validation workflow look like?

  1. Define the prediction task and metric. Reserve test examples that represent the intended use, holding out whole groups or later periods if appropriate.[1][3][12]
  2. Create a validation set or folds within the remaining development data. For each split, fit preprocessing such as scaling, imputation, and feature selection only on its training portion. Apply those fitted transformations to the held-out portion. A scikit-learn pipeline can do this separately for every fold.[13]
  3. Train candidate models, compare their validation results, and select hyperparameters or a stopping point. If the plan calls for refitting on all development data, use the selected settings and keep the test data out of that fit.[1][4][5]
  4. Evaluate the chosen model on the reserved test set. Report the metric and how the split was constructed, since a score on future periods or new participants answers a different question from a score on randomly held-out rows.[1][8][9]

Explain like I'm 5 (ELI5)

Imagine studying for a math test. Homework problems are the training set. A practice quiz is the validation set. If the quiz shows that fractions are giving you trouble, you can practice more before the real test. The real test is the test set. Its new questions show how well that practice worked. If you keep taking the same practice quiz, you may start remembering its answers.[1][2]

Continue reading

More to read

Topics:Machine Learning

References

  1. ^1 ^2 ^3 ^4 ^5 ^6 ^7 ^8 ^9 ^10 ^11Google. Datasets: Dividing the original dataset. Machine Learning Crash Course.
  2. ^1 ^2 ^3 ^4 ^5 ^6 ^7Gavin C. Cawley and Nicola L. C. Talbot. On Over-fitting in Model Selection and Subsequent Selection Bias in Performance Evaluation. Journal of Machine Learning Research, 2010.
  3. ^1 ^2 ^3 ^4 ^5 ^6 ^7 ^8 ^9 ^10 ^11 ^12 ^13Scikit-learn developers. Cross-validation: evaluating estimator performance.
  4. ^1 ^2 ^3 ^4 ^5Scikit-learn developers. Tuning the hyper-parameters of an estimator.
  5. ^1 ^2 ^3 ^4Keras. EarlyStopping.
  6. ^1 ^2 ^3Scikit-learn developers. Nested versus non-nested cross-validation.
  7. ^1 ^2 ^3Ron Kohavi. A Study of Cross-Validation and Bootstrap for Accuracy Estimation and Model Selection. IJCAI, 1995.
  8. ^1 ^2 ^3Sohrab Saeb and colleagues. The need to approximate the use-case in clinical machine learning. GigaScience, 2017.
  9. ^1 ^2 ^3Vitor Cerqueira, Luis Torgo, and Igor Mozetič. Evaluating time series forecasting models: an empirical study on performance estimation methods. Machine Learning, 2020.
  10. ^Ian Goodfellow, Yoshua Bengio, and Aaron Courville. Regularization for Deep Learning, section 7.8. Deep Learning, MIT Press, 2016.
  11. ^Jasper Snoek, Hugo Larochelle, and Ryan P. Adams. Practical Bayesian Optimization of Machine Learning Algorithms. NeurIPS, 2012.
  12. ^1 ^2 ^3Scikit-learn developers. Metrics and scoring: quantifying the quality of predictions.
  13. ^Scikit-learn developers. Common pitfalls and recommended practices, section on data leakage.

Improve this article

Add missing citations, update stale details, or write a clearer explanation. Anyone can edit: changes go live when you publish, and every edit is checked by an editor.

6 revisions · v6 · 1,916 words · full history

Fact-checks are independent of edits: a reviewer re-verifies the article against its sources and stamps the date. How we verify

Research and drafting on this wiki are AI-assisted, under named human editorial standards. How AI is used here

Reviewer note: Selecting a model by its validation score can make that score optimistic. An untouched test set or the outer folds of nested cross-validation can evaluate the selection procedure. The split must represent the intended prediction task.

Cite this page: AI Wiki. "Validation." aiwiki.ai, updated 1 Dec 2026, fact-checked 1 Dec 2026. CC BY 4.0. https://aiwiki.ai/wiki/validation

Edit article