Research methods · Machine learning
Cross-validation
Resampling model validation method
Cross-validation is a resampling method for estimating how a model will perform on data it has never seen, by splitting the available data repeatedly into a part used to build the model and a part held back to test it, and pooling the test results into an estimate of how the model would fare on new cases.
The appeal is that no fresh data need to be collected; the data at hand are made to stand in for the data that do not yet exist.
Key facts
| 38% | Share of null datasets where tuned SVM reported under 30% error (Varma and Simon 2006)[1] |
|---|---|
| 1000 | Sample size at which k-fold bias was still evident in simulations (Vabalas et al. 2019)[2] |
| 0.13 | Low end of misclassification across repeated nested runs on bbb2 (Krstajic et al. 2014)[3] |
| 8.3% | Share of 169 autoimmune ML studies combining cross-validation with independent testing (Stafford et al. 2020)[4] |
Overview
Cross-validation
A common form is k-fold cross-validation. The data are divided at random into k subsets, called folds. The model is trained on all folds but one, then tested on the fold left out; the process rotates until every fold has served once as the test set, and overall performance is the average across the k runs.[4] With 1,000 patients and ten folds, each fold holds 100 patients: the model is built on 900, tested on the remaining 100, and the cycle repeats ten times, so every patient is predicted exactly once by a model that never saw them during training.

The reason for the holding back is simple. A model assessed on its own training data is grading its own homework, and the resulting error is too low, often dramatically so when the sample is small. Cross-validation avoids this by ensuring that each prediction is made for a case the model did not learn from. It also makes efficient use of scarce data, since every case serves both for training and, in a different round, for testing.
That guarantee holds only if the entire modelling procedure is repeated inside each split. If a step such as choosing which variables to include, or setting a tuning parameter, is carried out once on the full dataset before the folds are formed, information from the held-out cases has already leaked into the model, and the cross-validation estimate becomes optimistic [3, 7]. The estimate is then no longer a fair forecast of performance on genuinely new data, which is the one thing it is meant to provide. Keeping every decision inside the loop is the discipline that makes the number trustworthy, and the sections that follow take up how the procedure is organised, how many folds to use, and where it tends to go wrong.
Cross-validation estimates future performance by testing each case with a model that was built without it; the estimate is only honest if every modelling decision is remade inside each split.
History
Where the idea came from
The practice of holding data back to test a model did not arrive all at once. Allen, Stone and Geisser are credited with independently introducing cross-validation as a way of estimating the parameters of predictive models so that predictions would improve.[3] Each contributed a different piece of what is now standard machinery.

Allen proposed the PRESS criterion, short for Prediction Sum of Squares, for problems involving the selection of predictors. PRESS is equivalent to leave-one-out cross-validation, the version in which a single case is set aside at a time, and Allen suggested it for general use.[3] The idea was that a model's predictive worth could be judged by how well it predicted each case when that case had been excluded from the fitting, rather than by how closely it matched the data it was built from.
Stone's contribution was conceptual as much as technical. He suggested leave-one-out cross-validation both for estimating model parameters and for assessing their predictive error, and he was the first to draw a clear line between two different jobs that the same procedure can do: cross-validatory choice, in which cross-validation is used to pick a model, and cross-validatory assessment, in which it is used to judge one.[3] The distinction matters because the two jobs make different demands on the estimate, a point that later work would press hard. Geisser then introduced the Predictive Sample Reuse Method, a procedure equivalent to V-fold cross-validation, arguing that it improves the predictive performance of the cross-validatory choice at the cost of introducing pseudo-randomness into the process.[3] That trade, better selection in exchange for results that shift from one random split to the next, is the reason repetition later became part of recommended practice.
A separate line of development addressed a practical obstacle: the computational burden of cross-validation when the model is a regularised regression. Choosing the ridge parameter, the penalty that shrinks coefficients toward zero, by ordinary cross-validation means refitting the model for every candidate value and, in leave-one-out form, effectively once per data point. Generalized cross-validation, or GCV, was developed as a rotation-invariant version of Allen's PRESS that can be computed from quantities already available in the fit, so the penalty parameter can be chosen from the data without an explicit refitting loop. GCV behaves like a risk-improvement estimator but does not require an estimate of the noise variance, which makes it usable when the number of observations barely exceeds the number of predictors, or even in some cases when predictors are at least twice the number of observations.[5] GCV thus extended the reach of the cross-validation idea to settings where the plain version would have been too slow or too unstable to apply.
What these early contributions established was a template rather than a finished method. The template has three parts: fit the model repeatedly with portions of the data removed, test it on what was removed, and combine the results into a single number. Everything that follows in later sections concerns how those portions should be chosen, how many there should be, and what the resulting number can honestly be said to measure.
How it works
Why a model cannot grade its own homework
The problem cross-validation exists to solve is easiest to see in the smallest possible example. Suppose a model has been fitted to a set of patients and is then asked to classify those same patients. It will do well, because the fitting procedure adjusted the model precisely so that it would. The error measured this way is called the re-substitution error, and it is known to be falsely low, usually zero when the sample is small.[1] Nothing has been learned about the patients the model will actually meet.
The clean remedy is a training/test split: fit the model on one portion of the data and measure its error on a separate portion that played no part in the fitting. The mean error on a sufficiently large test set, ideally an infinite one, is the true error of the classifier.[1] The logic is airtight, and so is the cost. The test cases are spent: they cannot also be used to build the model, so half or a third of an already limited sample is set aside and contributes nothing to the fit. When data are plentiful this is a bargain. When they are not, it is a waste.
How much of a waste depends on how small the sample is. In a study of quantitative structure-activity models, where the available compounds numbered in the dozens or scores rather than the hundreds, holding a portion back for testing was judged wasteful, and using the whole pool for both fitting and assessment through cross-validation was held to be much better, provided the cross-validation was done properly.[6] The same tension appears in microarray work, where the number of samples is tiny next to the number of features measured on each one, and splitting off a large test set is usually not feasible.[1] The data are too few to divide and too valuable to discard.
Cross-validation is the substitute. Rather than fixing one test set aside forever, it treats the data as a rotating pool: each case is held out in turn while the model is built on the rest, so every case serves once as a test case and, in other rounds, as part of the training material. No case is wasted, and no case is ever tested by a model that has seen it. The price is computation, since the model must be fitted many times instead of once, and a certain bookkeeping discipline, since the held-out portion has to be genuinely held out at every step of the procedure and not merely at the final fit.
That last point is where the reasoning becomes subtle, and it is the thread running through the rest of this chapter. The re-substitution error is too low because the model has seen the answers. A cross-validation estimate is too low for the same reason whenever information from the held-out cases has crept into any stage of model building, whether that stage is the final fit or an earlier decision about which variables to keep. The estimate is only as honest as the separation between the two roles each case plays.
A model scored on its own training data is graded on work it has already seen; cross-validation restores the separation by making every case, in turn, a stranger to the model that judges it.
The mechanics of k-fold and leave-one-out
The procedure is easiest to follow as a sequence of concrete steps. Take a dataset of 1,000 patients and choose ten folds.[2] The cases are divided at random into ten groups of 100. In the first round the model is trained on folds two through ten, that is, on 900 patients, and then asked to classify the 100 patients in fold one, none of whom it has seen. In the second round fold two is held out and the model is rebuilt from scratch on the other nine folds. The rotation continues until each of the ten folds has served once as the test set, at which point every patient has been predicted exactly once, always by a model built without them. Overall performance is the average of the ten round-by-round results.[4]
Two features of that description carry most of the weight. The first is that the model is rebuilt in every round rather than merely re-tested. A model trained once on 900 patients and then evaluated on ten different held-out groups would not be a cross-validation at all; the point is that each round's model is a fresh fit to a different subset, so the ten results reflect the variability of the modelling procedure and not just the luck of one fit. The second is that the folds are assigned at random, which is what makes the average a fair summary: no fold is systematically easier or harder than another, so the pooled result is not dominated by an unlucky partition. The averaging is not a formality. It is what turns ten noisy individual estimates into one estimate with a smaller spread than any single round could provide.
Leave-one-out cross-validation is the limiting case of the same scheme. Instead of holding out a fold of many cases, it holds out exactly one case per round, fits the model to all the remaining n − 1 cases, tests on the single excluded case, and repeats until every case has been excluded once.[7] With 1,000 patients that means 1,000 fits. The attraction is that each model is trained on almost the entire dataset, so the fit in each round is as close as possible to the fit that would be made on all the data. The cost is computational, since the number of fits equals the number of cases, and the procedure is deterministic: there is no random partition, so running it twice on the same data gives the same answer.
The trade-off between the two forms is a matter of bias and variance in the estimate itself. Leave-one-out trains on n − 1 cases, so the models it assesses are almost identical to the final model, and the estimate is therefore nearly unbiased for the performance of a model built on the full sample, though the source notes an inherent bias from using a subset of training samples in each round.[1] The k-fold version trains on a smaller fraction of the data, roughly (k − 1)/k of it, so its models are somewhat weaker than the final one. Against that, leave-one-out's near-identical training sets make its rounds highly correlated with one another, and averaging correlated results does less to reduce variance than averaging independent ones. Leave-one-out tends to select models with higher variance, which can lead to overfitting, which is why V-fold cross-validation is often preferred.[3] Which matters more depends on the sample size and on what the estimate will be used for, and the choice of k, which governs the balance, is taken up later.
A small worked contrast makes the difference concrete. With ten folds, each round trains on 90 percent of the data and tests on 10 percent, and the ten test results are pooled.[7] With leave-one-out, each round trains on 99.9 percent of the data and tests on a single case, and the 1,000 single-case results are pooled.[8] With ten folds, each round trains on nine-tenths of the data and tests on one-tenth, and the ten test results are pooled; with leave-one-out, each round trains on all but one case and tests on a single case. Both answer the same underlying question, how well the modelling procedure will do on cases it has not seen, but they answer it with different amounts of bias and different amounts of noise.
Neither scheme is a guarantee. The estimate they produce is an estimate of the performance of the procedure, and it inherits whatever flaws the procedure has. If a step of model building was performed on the full dataset before the folds were formed, both forms will report an optimistic number.[1][3][2] The mechanics described here are the skeleton; what makes the resulting number trustworthy is the discipline of keeping every modelling decision inside each round, and what makes it precise is the choice of how many cases to hold out at a time.
K-fold and leave-one-out are the same rotation with different batch sizes: k-fold trades a little bias for stability, leave-one-out trades stability for near-zero bias.
Choosing the number of folds
The number of folds, k, is the one setting every user of cross-validation must pick, and it governs three things at once: how long the procedure takes, how biased the resulting estimate is, and how much the estimate wobbles from one run to the next. With k folds, each round trains on roughly (k − 1)/k of the data.[4] Small k means each model is built on a modest fraction of the sample, so it is weaker than the model that will finally be fitted to everything, and the estimate is pulled pessimistically. Large k means each model is nearly full strength, so the bias shrinks, but the rounds become more alike and their results more correlated, which blunts the benefit of averaging. The computational bill rises with k as well, since the model is refitted k times.
Leave-one-out sits at the extreme, with k equal to the number of cases. Its near-unbiasedness was noted earlier; the other side of the ledger is that it tends to select models with higher variance, which leads to overfitting, and this is one reason the authors of use V-fold cross-validation.[3] A related analysis of the k-fold estimator separates its variance into two sources, sensitivity to changes in the training set and sensitivity to changes in the folds, and compares bias and variance across values of k on artificial data where the quantities can be computed exactly.[9] The practical upshot is that k is a dial trading bias against stability, not a free parameter with one correct setting.
Empirical work gives a sense of how flat that dial is across its middle range. One study trained four algorithms, gradient boosting, logistic regression, decision trees and k-nearest neighbours, on the same classification task using k values of 3, 5, 7, 10, 15 and 20, and found that the best value differed from one algorithm to the next. Across most of the algorithms, k = 7 gave a slight increase in validation accuracy and area under the curve, with less computation than k = 10. The gain was small: across most of the algorithms, k = 7 gave a slight increase in validation accuracy and area under the curve with less computation than k = 10, and five and ten are the most commonly used values, believed to give error estimates suffering neither from extremely high bias nor very high variance, though there is no formal rule.[10]
Two practical notes follow. First, the cost of large k is not only time but also the temptation to skip repetition, since a single leave-one-out run is deterministic and looks complete; the variability of estimates across different random splits, and what to do about it, is covered later. Second, when reporting the chosen parameter it is important to specify the details of the protocol, including the number of folds.[3] The next section turns to the more consequential question of what else must happen inside each fold.
Tuning inside the loop: nested cross-validation
Most models have settings that are not learned from the data in the ordinary sense but chosen by the person building the model: how many neighbours a nearest-neighbour classifier should consult, how strongly a penalty should shrink coefficients, how wide a kernel should spread. These are called hyperparameters, and the usual way to pick them is to try a range of values and keep the one that gives the best cross-validation result. That is a reasonable thing to do. The trouble starts when the same cross-validation number that guided the choice is then reported as the model's expected error.
The reason is that the choice itself is a form of training. When a value is selected because it scored best on a set of folds, information about those folds has entered the model, and the winning score is the best of several tries rather than an unbiased draw. A procedure that searches over settings and returns the best one is sometimes called a wrapper: cross-validation is wrapped inside a search that minimises the cross-validation error.[1] Once the wrapper is recognised as part of the modelling procedure, the fix follows naturally. The whole wrapper, search included, must be treated as the thing being assessed, which means it must sit inside a fresh cross-validation loop of its own.
That gives the nested cross-validation structure, two loops one inside the other. The inner loop does the tuning: within each training portion it runs its own cross-validation over candidate settings and picks the best. The outer loop does the assessment: it holds out a portion of the data, runs the entire inner procedure on the rest, and tests the resulting model on the held-out portion, repeating for different left-out portions.[1] The outer estimate never sees a setting chosen with knowledge of the case it is scoring, so it measures the performance of the full procedure, tuning and all, rather than the performance of a model that was handed the answers.
The distinction is easy to state and easy to get wrong, and the consequences are not subtle. A nested procedure is what makes the reported number an estimate of what a model built this way would do on new cases; without it, the number describes how well the search did at finding a good-looking fold, which is a different and much easier question. The section on tuning bias sets out the simulation evidence for how far apart the two numbers can fall. For now the structural point is enough: the inner loop chooses, the outer loop judges, and the two must not be the same loop.
A second layer of the same logic applies to the search itself. If the inner loop tries many candidate settings, the best of them will look good partly by luck, and the model chosen may be more complex than the data support. One response is the one standard error rule, which selects the most parsimonious model whose error is no more than one standard error above the best, rather than the outright minimum. With repeated cross-validation the standard error shrinks and the rule loses its effect, so it needs redefining in that context. The rule is a deliberate step back from the optimum in exchange for a simpler and usually more stable model, and it is one of several corrections proposed for the tendency of cross-validatory choice to favour complexity.[3]
Nested cross-validation also changes what the final number describes. It is not a property of the selected model alone but of the pair formed by that model and the protocol used to select it: the same data and the same winning setting can yield different nested estimates if the inner search scanned a different range of values, because the two searches incorporated different information into the choice.[3] This is not a defect. It is a reminder that the estimate answers a procedural question, how well this way of building a model will generalise, and that the protocol is part of what is being measured.
The cost is computation, since the inner loop multiplies the number of fits by the number of candidate settings and the outer loop multiplies that again. That cost is the main reason nested cross-validation is often skipped in favour of a single tuned estimate, and the reason its absence tends to go unnoticed: the single estimate is always available, always looks precise, and is optimistic in a way that leaves no trace in the output.
Tuning is training. Any setting chosen by looking at cross-validation scores must be chosen afresh inside each outer fold, or the reported error describes the search rather than the model.
The bias from tuning on the same estimate
The nested structure described earlier is not a matter of tidiness. Leaving the tuning outside the assessment loop produces a number that can be badly wrong, and the size of the error can be measured directly. The cleanest way to measure it is to build data in which there is nothing to find. If the features of two groups are drawn from the same distribution, no classifier can do better than chance on new cases, and any procedure that reports a low error on such a null dataset is reporting an illusion. Whatever accuracy it claims is bias, visible because the truth is known in advance.

A simulation study took exactly this approach with two classifiers, Shrunken Centroids and a support vector machine, or SVM, a classifier that separates two classes by a boundary chosen to leave the widest margin between them.[1] For each classifier the tuning parameter was selected the usual way: many candidate values were tried, cross-validation error was computed for each, and the value with the lowest error was kept. Ten-fold cross-validation was used for Shrunken Centroids and leave-one-out for the SVM. The error of the resulting tuned classifier was then recorded as though it were the model's expected performance. On data where the two classes were statistically identical, this recorded error fell below 30 percent on 18.5 percent of the simulated training sets for Shrunken Centroids and on 38 percent of them for the SVM. A procedure that cannot beat a coin flip was claiming, in more than a third of runs for one classifier, that it was right more than 70 percent of the time.[1]
The check that settles the question is to give the tuned classifiers genuinely new cases. When the same classifiers were applied to independent test data, their performance was no better than chance.[1] The low error had not travelled with the model, because it had never belonged to the model. It belonged to the search. Trying many settings and keeping the best is a selection among noisy numbers, and the minimum of a set of noisy numbers sits below their average even when all the settings are equally good. The reported figure was the luckiest draw, not a forecast.
The remedy is the nested arrangement: an inner loop tunes the parameters within each training portion, and an outer loop measures the error of the whole tuning-and-fitting procedure on cases the inner loop never saw. Run this way, the estimate came very close to the error obtained on the independent test set, for both classifiers and for both the null data and data with a real difference between the classes. The bias was reduced considerably, because the outer loop never allowed a setting to be chosen with knowledge of the case it was scoring.[1]
Two features of the result are worth carrying forward. The first is that the bias is a property of the procedure, not of the classifier: it appeared with two different classifiers and two different resampling schemes, ten-fold and leave-one-out, which suggests the mechanism is general rather than a quirk of one algorithm.[1] The second is that the bias runs in one direction. The inherent bias of a resampling estimate, the part that comes from training on fewer cases than the final model will see, can fall either way, but the part contributed by selecting the best of several noisy estimates is always negative, pulling the reported error below the truth.[1] An optimistic number is therefore the expected outcome whenever tuning and assessment share a loop, not an unlucky one.
The practical consequence is that a single cross-validation figure cannot distinguish a model that generalises from a search that got lucky, because both produce the same low number. Only the separation of the two loops, or a genuinely independent test set, can tell them apart. The next section takes up what happens to this same optimism when the sample is small, where the noise the search exploits is larger and the gap between reported and real performance widens further.
When the same cross-validation number both chooses the settings and reports the error, it reports the best of many noisy tries; the figure is optimistic by construction, and only an outer loop or fresh data can correct it.
Small samples and the optimism problem
The optimism described in the previous section is not a fixed quantity. It grows as the sample shrinks, because a small sample gives the search more room to find patterns that are not there. With few cases and many measured features, a model can fit the noise in the training data rather than any real signal, and a validation scheme that lets any information from the held-out cases into the fitting will report that noise-fitting as skill. The smaller the sample, the more of the reported accuracy is this artefact.
The clearest evidence comes from simulations in which the data contain no signal at all. If the features of two groups are drawn from the same distribution, no classifier can do better than chance on new cases, so any procedure that reports better than chance is reporting bias, visible because the truth is known in advance. A study of machine learning validation used exactly this design, generating random data with an expected classification accuracy of 50 percent, and compared five validation approaches while systematically varying the sample size. The result was stark: k-fold cross-validation produced strongly biased performance estimates with small samples, and a substantial bias remained even at a sample size of 1000. Nested cross-validation and a simple train/test split, by contrast, produced robust and unbiased estimates regardless of sample size.[2]
The persistence of the bias at 1000 cases is the part that unsettles the usual intuition. A thousand samples sounds like a comfortable dataset, and it is comfortable for many purposes, but it is not enough to make a single-loop cross-validation honest when the model has many adjustable features and the data are uninformative. The bias shrinks as the sample grows, yet it does not vanish at the sizes that much applied work actually has. Testing the algorithm on data that were also involved in its training was enough to produce biased results with small samples, and a substantial bias remained even at the larger sizes.[2]
The same study separated two stages of model building to see which one lets the leak in. Feature selection, the step that decides which measured variables enter the model, and parameter tuning, the step that sets the model's adjustable settings, were each performed in a non-nested fashion while the other was kept inside the loop. Performing only feature selection on the pooled training and testing data gave considerably biased results, while the bias was much smaller when only parameter tuning was done that way.[2] Feature selection is therefore the more dangerous of the two when it is done before the split, which fits the arithmetic: choosing a handful of variables from thousands on the basis of the full dataset is a powerful act of fitting, and it uses every case, including the ones that will later be held out.
That finding has a practical edge because of how common the pattern is. In a survey of neuroimaging studies that used supervised machine learning to classify healthy individuals and individuals with brain disorders, most of the surveyed studies had a small number of subjects, with a median of 88, and the overall reported accuracy was higher in the studies with smaller sample sizes. The pattern held across schizophrenia, mild cognitive impairment, Alzheimer's disease, depressive disorders, autism spectrum conditions and attention-deficit hyperactivity disorder. A separate survey of machine learning studies predicting autism from non-autism found a significant negative relationship between sample size and reported accuracy, with a correlation of −0.70.[2] Smaller studies were reporting better results, which is the signature of a validation method that rewards small samples rather than a discovery that small studies are better designed.
The survey also shows how the leak gets in without anyone intending it. Many neuroimaging studies proceeded in two parts: first, statistical tests such as t-tests identified which features differed between groups; second, those preselected features were used for classification.[2] The selection was performed on all the data, training and testing pooled together, so the classifier was tested on cases that had helped choose its inputs. The bias this introduces is not a subtle statistical nicety; it is the difference between a model that has learned a pattern and a model that has been told which variables to prefer by someone who had already seen the answers.
What makes the small-sample problem hard to notice is that the output looks the same either way. A biased estimate and an honest one are both single numbers, and the biased one is usually the more impressive. The simulations show that with non-discriminable data, k-fold cross-validation reports overoptimistic accuracy while nested cross-validation and the plain train/test split stay at chance.[2] The safeguard is structural rather than statistical: keep feature selection, tuning and every other decision inside the loop, and accept the lower number that results.
With small samples, a single-loop cross-validation can report strong accuracy on data that contain no signal at all, and the bias survives to sample sizes in the hundreds and beyond; only strict separation of training and testing, as in nested cross-validation, removes it.
Variability between runs and the case for repetition
Every cross-validation estimate is built on a partition of the data, and the partition is usually drawn at random. Draw it again and the folds contain different cases, the models are fitted to slightly different training portions, and the resulting number moves. The movement is not a sign that something has gone wrong; it is a property of the estimator. A single run therefore gives one draw from a distribution of possible estimates, and treating that draw as the answer ignores the spread around it.

The size of the spread can be large enough to change decisions. In a study of quantitative structure-activity models, datasets were analysed with ten-fold cross-validation, and no single run provided a reliable selection of the best model; robust selection required summarising the loss across multiple repetitions of the procedure, with the choice based on average loss. The same study found that the model-selection behaviour of a particular dataset could only be discerned once the cross-validation was repeated.[3]
Repetition also changes what can be said about the final number. When the whole selection procedure, tuning included, was placed inside an outer loop and that outer loop was itself repeated, the nested estimates of loss varied substantially from one repetition to the next. On the bbb2 dataset the proportion misclassified ranged between approximately 0.13 and 0.23 across repeated nested runs.[3] The practical reading is that the best model chosen on that data might have a large-sample error anywhere in that band, and whether such a band is acceptable depends on the application. Reporting the interval rather than a point is what allows that judgement to be made.
The reason a single run misleads is that the estimate carries both bias and variance, and repetition attacks the second without pretending the first is absent. Averaging over many random partitions smooths out the luck of any one split, so the summary reflects the modelling procedure rather than a particular arrangement of cases. The cost is computational, since each repetition multiplies the number of fits, and the arithmetic compounds quickly when an inner tuning loop sits inside each outer fold. The argument made for routine repetition is that affordable cloud computing has made the computational cost of repeated and nested cross-validation low enough that substitutes for full nested cross-validation are no longer justified.[3]
How the repetitions should be structured is a separate question from whether to do them. Repeating k-fold cross-validation means running the whole rotation several times with fresh random partitions and pooling the results. Repeating nested cross-validation means repeating the outer loop as well, so that each repetition yields its own estimate of the full procedure's error, and the collection of those estimates supplies the interval. The two are not interchangeable: the first stabilises the choice among candidate models, the second stabilises the assessment of the chosen one.
There is a caution attached to the pooling. The repetitions are not independent samples, because the same cases recur across them, and the correlation between results from different repetitions tends to be high, rising as the number of folds increases.[11] Treating repeated runs as though they were independent replicates therefore understates the variance of the pooled estimate. The suggestion that follows from this analysis is a large number of folds with a small number of repetitions.[11] Repetition buys stability, but it does not buy as much independent information as the raw count of runs would suggest.
What repetition cannot repair is a leak. If feature selection or tuning was performed on the full dataset before the folds were formed, every repetition inherits the same contamination, and averaging many contaminated estimates produces a precise version of the wrong number. Repetition improves the reliability of an honest procedure; it does not make a dishonest one honest. The pitfalls that produce that kind of contamination are taken up later, along with the question of what the resulting estimate actually measures.
A single cross-validation run is one draw from a spread of possible answers; repeating the procedure, and reporting the interval rather than a point, is what turns that draw into a defensible estimate.
What the estimate actually measures
The number that comes out of a cross-validation run is easy to read as a verdict on the model sitting on the analyst's desk. It is not that. The model fitted to the full dataset is a single object, and the folds never tested it; they tested a family of near-copies, each built on a slightly different portion of the data. What the pooled error describes is the average performance of models produced by the same fitting procedure on training sets drawn from the same population, not the performance of the one model that will actually be used.[12]
The distinction sounds academic until the two things are seen to diverge. For a linear model fitted by ordinary least squares, it can be proved that cross-validation does not estimate the prediction error of the model at hand, fitted to the training data, but rather the average prediction error of models fitted on other, unseen training sets from the same population. The same holds for most popular estimates of prediction error, including a single data split, bootstrapping and Mallow's Cp.[12] The estimate is therefore a statement about a procedure, and the procedure is what was assessed. A particular fitted model may do better or worse than that average, and cross-validation has nothing to say about which.
This matters most when the estimate is used to attach a range to a forecast. The usual confidence interval around a cross-validation error treats the fold results as though they were independent measurements, and they are not. Each case is used both for training and, in another round, for testing, so the accuracies measured on different folds are correlated with one another, and the ordinary variance calculation comes out too small.[12] The consequence is an interval narrower than it should be, one that claims more precision than the procedure has earned. The standard intervals derived from cross-validation can have coverage far below the desired level for exactly this reason.[12]
A remedy follows the same logic as the nested structure used for tuning. If the variance is understated because the folds are entangled, the entanglement can be broken by placing the whole cross-validation inside an outer loop, so that the outer loop measures how much the inner estimate moves from one training portion to the next. Such a nested scheme estimates the variance more accurately, and in many examples where the traditional intervals fail, the resulting intervals have approximately correct coverage.[12] The point is not that every reported error needs such an interval, but that the error and its uncertainty are two separate quantities, and the second does not come free with the first.
One further caution attaches to the practice of refitting. When a model's accuracy is estimated by a simple split and an interval is wanted for that accuracy, refitting the model on the combined data afterwards invalidates the interval.[12] The refitted model is a different object from the one whose error was measured, and the interval belongs to the measurement, not to the refit. The general lesson runs through the whole procedure: the number describes the process that produced it, and changing the process after the fact leaves the number behind.
Cross-validation reports the average error of models built by a procedure on other training sets, not the error of the single fitted model, and its usual intervals are too narrow because the folds are correlated.
Cross-validation in the wild
The methods described so far are not confined to statistics journals. They are used, and sometimes skipped, in medicine, epidemiology and machine learning research, and the published literature shows both what careful validation looks like and what happens when it is left out.
A clinical prediction model is a formula that turns routine measurements into a risk estimate, and its value depends entirely on whether it works in patients it has not met. One family of such models, early warning scores, uses vital signs recorded during a hospital stay to flag patients who may be deteriorating, and in the United Kingdom their use is mandated as a standard of care. Because inpatients are assessed every few hours, these scores are applied hundreds of millions of times a year, which makes the quality of their validation a matter of direct patient safety rather than academic tidiness.[13]
A systematic review of 95 studies that developed or externally validated such scores found the validation step frequently mishandled. Internal validation, the check on how optimistic a new model's apparent performance is, was carried out in 19 studies, but recommended approaches such as bootstrapping or cross-validation were used in only 4 of those 19, about 22 percent. Of the 16 articles whose development studies internally validated their early warning score, 11 used a split sample approach, which the review describes as weak and inefficient. The review's broader finding was that all included studies were at high risk of bias, with calibration seldom assessed in validation studies (13 of 84, 15 percent) and key details of the analysis populations often unreported. A score whose development was never properly checked may not perform as expected in use, and the review notes that this could have a detrimental effect on patient care.[13]
The pattern repeats in newer, data-hungry fields. A systematic review of 169 studies applying machine learning to autoimmune disease found that support vector machines and random forests were the most popular methods, and that models using data on multiple sclerosis, rheumatoid arthritis and inflammatory bowel disease were most common.[4] Validation practice was uneven. Eighteen studies used only a single hold-out split, and eleven used no validation method at all, leaving model integrity unconfirmed. Only 14 of the 169 studies, 8.3 percent, combined cross-validation with a separate testing set for a more robust evaluation. The review treats that combination as the standard worth aiming for, recommending it as a best practice for validating machine learning models.[4]
Why the combination matters is visible in a single comparison from the same review. One machine learning model was evaluated both by cross-validation and then on an additional independent test dataset, and its area under the curve dropped by 0.25 on the new data.[4] The cross-validated figure had been the more flattering of the two, and the independent data revealed the gap. A separate observation in the review points the same way: six models reported perfect performance, with measures such as accuracy or area under the curve at 1 or 100 percent, a result the authors suggest may reflect poor implementation of cross-validation rather than a genuinely flawless classifier.[4]
Not every field neglects the separation. A well-known equation for estimating kidney function, the CKD-EPI equation, was built and checked on two distinct pools of data. The equation estimates glomerular filtration rate, a measure of how well the kidneys filter waste, from a blood test for creatinine together with sex, race and age. It was developed on 8,254 participants from 10 studies and then validated on 3,896 participants from 16 separate studies, with measured filtration rate as the yardstick in both. On that independent validation set the new equation showed less bias than the older equation it was meant to replace, with a median difference between measured and estimated filtration rate of 2.5 against 5.5 millilitres per minute per 1.73 square metres, a narrower interquartile range of the differences, and a higher percentage of estimates falling within 30 percent of the measured value, 84.1 against 80.6 percent.[14] The comparison carries weight precisely because the validation participants played no part in building the equation.
The three cases differ in method but agree on the underlying point. Cross-validation, a hold-out split and an independent dataset are all ways of arranging for a model to be judged on cases it did not learn from, and the reviews find that this arrangement is often absent, partial or applied in a form that wastes data. The specific errors that produce optimistic numbers, and the alternatives to cross-validation such as bootstrapping and information criteria, are covered later.
Across clinical prediction and machine learning reviews, the recurring weakness is not the choice of validation technique but whether a genuinely untouched set of cases was ever used to judge the model.
FROM THE STUDY [13]
Most common predictors included in early warning scores
Breathing rate was the most commonly included predictor, in 30 of 34 scores, followed by heart rate in 28. Age and sex were included far less often, in 13 and 3 of the 34 scores.
Exact supplied values
| Record ID | Source | Source locator | Group | Numerator | Denominator |
|---|---|---|---|---|---|
| g1-respiratory-rate | paper | “The most common predictors were respiratory rate (n=30/34, 88%), heart rate (n=28/34, 83%), oxygen saturation, temperature, and systolic blood pressure (all n=24/34, 71%).” | Respiratory rate | 30 | 34 |
| g2-heart-rate | paper | “The most common predictors were respiratory rate (n=30/34, 88%), heart rate (n=28/34, 83%), oxygen saturation, temperature, and systolic blood pressure (all n=24/34, 71%).” | Heart rate | 28 | 34 |
| g3-oxygen-saturation | paper | “The most common predictors were respiratory rate (n=30/34, 88%), heart rate (n=28/34, 83%), oxygen saturation, temperature, and systolic blood pressure (all n=24/34, 71%).” | Oxygen saturation | 24 | 34 |
| g4-temperature | paper | “The most common predictors were respiratory rate (n=30/34, 88%), heart rate (n=28/34, 83%), oxygen saturation, temperature, and systolic blood pressure (all n=24/34, 71%).” | Temperature | 24 | 34 |
| g5-systolic-blood-pressure | paper | “The most common predictors were respiratory rate (n=30/34, 88%), heart rate (n=28/34, 83%), oxygen saturation, temperature, and systolic blood pressure (all n=24/34, 71%).” | Systolic blood pressure | 24 | 34 |
| g6-age | paper | “Age (n=13/34, 38%) and sex (n=3/34, 9%) were less frequently included.” | Age | 13 | 34 |
| g7-sex | paper | “Age (n=13/34, 38%) and sex (n=3/34, 9%) were less frequently included.” | Sex | 3 | 34 |
Study context and limitations
Population: Gerry, S., Bonnici, T., Birks, J., Kirtley, S., Virdee, P. S., Watkinson, P. J., & Collins, G. S. (2020). Early warning scores for detecting deterioration in adult hospital patients: systematic review and critical appraisal of methodology. BMJ , m1501. doi:10.1136/bmj.m1501
Design: Review. Each bar is a count out of its own total, both exactly as the source prints them.
Selection: The 7 counts the source's text prints together with a total.
Limitations: Values are exactly as printed in the source; nothing was calculated, rounded or inferred. A difference between rows is not by itself a causal comparison.
Sources and provenance
- Gerry, S., Bonnici, T., Birks, J., Kirtley, S., Virdee, P. S., Watkinson, P. J., & Collins, G. S. (2020). Early warning scores for detecting deterioration in adult hospital patients: systematic review and critical appraisal of methodology. BMJ , m1501. doi:10.1136/bmj.m1501 · Abstract and open full text (the open-access PDF where one exists) as retrieved for this article
Source titles, citations and record identifiers remain in their original form.
Worked example
Cross-validation in crystallography: the free R value
A held-out set of reflections
X-ray crystallography builds an atomic model by fitting it to measured diffraction data, and the quantity that reports how well the model matches those data is the R value, a measure of the disagreement between the observed reflection intensities and the intensities the model predicts. The trouble is the same one that afflicts any fitted model: refinement adjusts the atomic coordinates until the R value falls, so a low R value partly reflects the fitting rather than the correctness of the structure. A model can be refined into a wrong arrangement of atoms and still show a respectable R value, because the refinement has used every reflection to achieve it.
The free R value applies the cross-validation idea to this problem. Because those reflections played no part in fitting the atoms, the free R measures how well the model predicts data it has not seen, which is precisely what the ordinary R value cannot do. Analogies between the free R statistic and the statistical methods of cross-validation and bootstrap are discussed, and the free R value was shown to correlate with the accuracy of the derived phases, the estimated positions of the atoms in the crystal.[15]
The free R value provides an objective statistical basis for choosing the relative weights of individual restraint classes. In one application, the free R value supplied an objective basis for choosing the relative weights given to different classes of restraints, the geometric conditions that keep bond lengths and bond angles within chemically sensible limits during refinement. Judging by the free R value asks instead which weights produce a model that predicts the reflections it never saw, and on a penicillopepsin structure refined at 1.8 Å resolution this pointed to bond-length and bond-angle weights derived from uncertainties measured in small-molecule crystal structures, suggesting those weights carry over to macromolecules.[15]
The same logic was turned on a harder question: whether the free R value could distinguish a roughly correct arrangement of atoms from an incorrect one. The test used unrestrained modelling of the diffraction data with equal atomic scatterers, a simplified picture in which every atom scatters alike, and examined the landscape of R values around the true structure.[15] A large number of incorrect configurations of the scatterers had ordinary R values close to that of the correct configuration, so the working R value alone could not separate them. A substantial number of those incorrect configurations, however, had higher free R values than the correct one. A substantial number of the incorrect configurations had higher free R values than the correct one, so it is conceivable that the free R value could be used as a selection criterion., and the free R value could in principle be used as a selection criterion to tell certain incorrect configurations apart from ones close to the correct structure.[15]
That result is the crystallographic version of a lesson met throughout this chapter: a fit judged on the data it was fitted to will flatter a wrong model, and only cases excluded from the fitting can expose the difference. The free R value is not a separate statistical technique so much as the cross-validation principle applied where the "cases" are individual reflections rather than patients or compounds, and where the model is a set of atomic coordinates rather than a classifier.
The wider validation of crystal structures extends the same concern beyond the refinement itself. Local errors that can affect biological interpretation are widespread at low resolution, and even high-resolution structures nearly all contain at least a few local errors such as Ramachandran outliers, flipped branched protein side chains and incorrect sugar puckers. Validation tools such as MolProbity examine the model's geometry and all-atom contacts to diagnose and correct local errors.[8]
The free R value holds back a small set of reflections from refinement and judges the model on those alone, so that a structure is scored on data it was not fitted to.
Uses
Choosing between cross-validation and an external validation sample
Two kinds of held-out data

Cross-validation and an external validation sample both arrange for a model to be judged on cases it did not learn from, but they answer different questions. Cross-validation reuses the data at hand, rotating which portion is held back, and so estimates how a modelling procedure behaves on new cases drawn from the same population as the original sample. An external validation sample is a separate collection of cases, gathered at other times, in other places, or from other institutions, and it tests whether the model travels to those settings. The first asks whether the procedure generalises within its own population; the second asks whether the population it was built for is the population it will meet.
The difference is easiest to see in a model that was checked both ways. The CKD-EPI equation for estimating kidney function was developed on one pooled dataset of 3,896 participants from 16 studies and then validated on a separate pool of 8,254 participants from 10 different studies, with measured filtration rate as the yardstick in both.[14] In the validation data set, the CKD-EPI equation performed better than the Modification of Diet in Renal Disease Study equation, with less bias (median difference between measured and estimated GFR, 2.5 vs. 5.5 mL/min per 1.73 m²), improved precision (IQR of the differences, 16.6 vs. 18.3 mL/min per 1.73 m²), and greater accuracy (84.1% vs. 80.6% of estimates within 30% of measured GFR).[14] A cross-validation inside the development pool could have told the developers how stable their equation was, but it could not have told them how the equation would behave in sixteen studies it had never touched.
What a big dataset adds
External validation becomes more informative when the separate data are large and varied, because a single overall performance figure can hide disagreement between settings. Access to big datasets from e-health records and from pooled individual participant data allows a model's discrimination and calibration to be checked across clinical settings, populations and subgroups, and simply reporting performance averaged over all clusters and individuals is not sufficient, since the average can mask important deficiencies in particular groups. Where performance is inconsistent, users need to know the magnitude of the inaccuracy and in whom it arises, and whether recalibration or some other updating strategy is needed for a given setting and by how much it helps. Sometimes no amount of tailoring will do, and an entirely new model is required; a risk score developed from practices serving a predominantly white population, for example, is unlikely to perform as well across the wider population of the United Kingdom where predictor effects and baseline risks differ between ethnic groups.[16]
Using the two together
The two forms of validation are complements rather than rivals. A systematic review of 169 studies applying machine learning to autoimmune disease found that only 14, or 8.3 percent, combined cross-validation with a separate testing set for a more robust evaluation, and the review suggests the field may benefit from adopting a best practice of validation, cross-validation and independent testing of ML models. The review cites a model by Ahmed et al. in which the AUC dropped by 0.25 on an additional independent test dataset, as evidence for using an independent test set subsequent to cross validation.[4] Cross-validation had given the more flattering figure, and the independent sample revealed the gap. Cross-validation makes efficient use of scarce data and exposes the optimism of a single fit; an external sample shows whether the model survives the move to a new population. A model intended for use beyond the data that produced it is best served by both.
Common mistakes
Pitfalls in practice
The errors that spoil a cross-validation estimate are few in number and remarkably persistent. They share a common shape: some decision that belongs inside the loop is made outside it, or a number produced for one purpose is reported as though it served another. Naming them plainly is most of the defence, because each leaves a characteristic trace in the way a study is described.

The first is selecting variables before the loop. Suppose a dataset holds thousands of measured features and a few dozen cases, and the analyst first screens the features on the whole dataset, keeping only those that differ between the groups, then runs a tidy cross-validation on the survivors. The folds are clean in the narrow sense that no case is in both the training and the test portion of a given round. But the screening already used every case, including the ones that will later be held out, to decide which features the model is allowed to see. The held-out cases have influenced the model's inputs, and the estimate that follows is optimistic. The rule is that variable selection must be repeated within each fold, on the training portion alone, so that the features chosen in a round are chosen without knowledge of the cases that round will test.
The second is choosing a model on the basis of a single cross-validation run. A single partition of the data yields one ranking of the candidate models, and that ranking is partly an accident of which cases landed in which fold. In an analysis of QSAR datasets using ten-fold cross-validation, no single run provided a reliable selection of the best model; robust selection required summarising the loss across multiple repetitions and choosing on the average. The model-selection behaviour of a particular dataset became discernible only once the procedure was repeated.[3] A ranking read off one run may therefore reflect the split rather than the models, and the remedy is repetition rather than a larger number of folds.
The third is reporting a cross-validation error as the error of the selected model. This is the subtlest of the group, because nothing improper has been done at any single step. A search over settings or over candidate models is run, cross-validation scores each candidate, the best is kept, and its score is written down as the expected performance of the winner. But that score is the minimum of several noisy numbers, and a minimum sits below the average of the numbers it was drawn from even when all the candidates are equally good. The figure describes the search, not the model. Separating the two requires the nested arrangement described earlier, in which an outer loop measures the whole selection procedure on cases the inner search never saw.
The fourth concerns imbalanced data, where one class is far rarer than the other and a classifier can score well by ignoring the rare class altogether. A standard fix is oversampling, in which cases from the minority class are duplicated or synthesised until the classes are more evenly represented. The pitfall is to apply the oversampling to the entire dataset before the folds are formed. Duplicated cases then appear in both the training portion and the test portion of the same round, so the model is tested on material it has effectively already seen, and the resulting estimate is both overoptimistic and overfitted.[17] The correction follows the same principle as before: oversampling belongs inside the loop, applied only to the training portion of each round, so that the test portion remains untouched by the balancing procedure.
These four failures are variations on one theme, which is that the boundary between training and testing must be respected at every stage of model building and not merely at the final fit. A procedure can look meticulous, with folds carefully drawn and every case tested exactly once, and still leak information at an earlier step. The leak is invisible in the output, because a contaminated estimate and an honest one are both single numbers, and the contaminated one is usually the more impressive. What exposes it is the description of the method: whether the screening, the tuning, the model choice and any resampling of the classes were each performed afresh within every fold. The alternatives to cross-validation, and the situations in which its estimates become too variable to trust, are taken up in the sections that follow.
The recurring failure is a decision made once on all the data and then carried into every fold; the test is whether each step, from variable selection to oversampling, was redone inside each round.
Cross-validation when the data are not independent: spatial and grouped structure
When the cases know each other

Ordinary cross-validation rests on an assumption that is rarely stated: the held-out cases must be exchangeable with the training cases, drawn from the same pool with nothing linking them. When observations come from places, patients, schools or time periods that cluster, that assumption breaks. A held-out site near a training site shares its climate, its soil and its species pool; a held-out patient from the same clinic shares its referral patterns. The model can then score well on the held-out case not because it has learned a general rule but because it has learned the neighbourhood, and the estimate inherits an optimism that no amount of folding removes.
Species distribution models make the failure visible, because geography supplies a natural measure of resemblance. These models relate recorded occurrences of a species to environmental variables and predict where else it might live, and they are usually evaluated by cross-validation, with evaluation statistics computed from predictions at presence and absence sites that were not used to fit the model. The problem is what is called spatial sorting bias: the difference between the geographic distance from testing-presence sites to training-presence sites and the distance from testing-absence or testing-background sites to those same training sites.[18] If the held-out presences sit closer to the training presences than the held-out absences do, the model gets an easy hint about the answer from location alone, and its apparent skill is partly an artefact of how the data were divided.
The size of the distortion was measured across 226 species in six regions, using two modelling algorithms, Bioclim and MaxEnt. Evaluation results were strongly inflated: a null model that considered only the geographic distance to training sites performed better than MaxEnt for 45 percent of the species and better than Bioclim for 67 percent.[18] A procedure with no environmental information at all was beating the real models on a large share of cases, which is a direct demonstration that the cross-validation was rewarding proximity rather than prediction. The inflation grew worse when partitioned presence data and random-absence data were used instead of independently obtained presence-absence testing data from systematic surveys.[18]
Two corrections were proposed. Pairwise distance sampling removes spatial sorting bias, yielding null models with an area under the curve close to 0.5, the level of a coin flip. Pairwise distance sampling removed the bias, yielding null models with an AUC close to 0.5, and this adjustment strongly decreased the area under the curve values and changed the ranking among species; calibration with an appropriate null model adjusts the remaining bias. The practical consequence is that results for different species are comparable only after the bias is removed or the calibration applied.[18]
The same lesson appears from the training side. A study of regional-scale land cover classification compared four ways of selecting training samples, simple random, proportional stratified random, disproportional stratified random and deliberative sampling, and three cross-validation tuning approaches, k-fold, leave-one-out and Monte Carlo, using support vector machines on high-resolution imagery and lidar-derived rasters over a 2,609 square kilometre area of northeastern West Virginia. Stratified statistical sampling gave the highest accuracy, and classifiers trained on deliberately chosen samples were less accurate than those trained on statistical samples, possibly because the deliberative training set carried high positive spatial autocorrelation.[19] Hand-picked training points that sit close together teach the model about one patch of ground, and the resulting classifier travels poorly.
The remedy in both cases is to make the split respect the structure of the data rather than ignore it: hold out whole regions, sites or clusters, so that no testing case has a near neighbour in the training set. The estimate that results is lower and less flattering, and it is the one that answers the question actually being asked, which is how the model will behave in a place it has never been.
When cases cluster in space or in groups, a random split lets held-out cases be predicted from their neighbours; holding out whole clusters gives the honest, lower number.
Alternatives
Bootstrapping, holdout and information criteria
Alternatives to rotation
Cross-validation is one way of arranging for a model to be judged on cases it did not learn from, and it is not the only one. The three main alternatives differ in how much data they spend on the judging and how much computation they charge for it. A holdout split is the simplest: the data are divided once, the model is built on one part and scored on the other, and the score is reported. It costs a single fit, which is why it is popular, but it spends the held-out cases permanently and the resulting estimate depends heavily on which cases happened to land in the test portion.
Bootstrapping takes a different route. Many new datasets are drawn from the original by sampling cases with replacement, so each new dataset contains some cases more than once and omits others; a model is fitted to each and scored on the cases left out. Because the omitted cases differ from draw to draw, the procedure can be repeated cheaply and the results averaged, which smooths out the luck of any single partition. The plain bootstrap estimate, however, is biased, and the.632+ rule was introduced to correct it.
The trade is visible in small-sample comparisons. A simulation study of microarray classification compared cross-validation, re-substitution and bootstrap estimation for three classifiers, linear discriminant analysis, three-nearest-neighbour and classification trees, on both synthetic and real breast-cancer data. Cross-validation was much less biased than re-substitution, as expected, but it displayed excessive variance, which made individual estimates unreliable when samples were small; bootstrap methods gave improved performance with respect to variance, at a high computational cost and often with somewhat increased bias, though far less bias than re-substitution.[20] The practical reading is that the two procedures fail in different directions, and neither is uniformly better.
The cost of a holdout split is not only wasted data but instability, and the size of the penalty has been measured in software engineering. An analysis of 101 public defect datasets, the historical records used to predict which code modules are likely to contain bugs, found that 77 percent of them were highly susceptible to producing unstable results, making the choice of validation technique a critical design decision.[21] From 256 studies in the defect prediction literature the authors selected the 12 most commonly used validation techniques and compared them on 18 systems. Single-repetition holdout validation produced estimates with 46 to 229 percent more bias and 53 to 863 percent more variance than the top-ranked techniques, while out-of-sample bootstrap validation gave the best balance between the two.[21] A single split, in other words, is not merely a cheaper version of the rotation; it is a systematically worse estimator, and the gap is large enough to change which model looks best.
Information criteria approach the problem from the opposite direction. Rather than resampling the data, they add a penalty for model complexity to the fit achieved on the training data, so that a model is charged for each parameter it spends. Cross-validation is correspondingly more versatile: it can be applied where a likelihood cannot be written down, as with many machine learning methods, or where the number of parameters cannot be counted precisely, as with mixed-effects models.[22] The choice between the two families therefore turns on whether those assumptions hold and whether a defensible likelihood is available, not on which gives the more accurate number in general.
What the alternatives share with cross-validation is the underlying requirement that the judging cases play no part in the building. A holdout split, a bootstrap sample and a complexity penalty all attempt to answer the same question, and all of them can be defeated by the same leak: a variable selection or a tuning step performed once on the full dataset before the procedure begins. The differences among them concern bias, variance and computational cost, and those differences are real, but none of them repairs a contaminated estimate. The remaining limits of the cross-validation approach itself, including how its variance behaves in very small samples and how protocol details shift the answer, are covered later.
A holdout split is cheap and unstable, bootstrap is stable and costlier, and information criteria avoid resampling altogether by charging for complexity; all three still require that no modelling decision be made on the cases that will judge the model.
Limits and open disputes
Cross-validation is a good estimator, not a perfect one, and its weaknesses are well enough documented that a careful user should know where the number is likely to mislead. Three of them recur: the estimate can be too noisy to act on when the sample is small, one of its most intuitive forms can fail at the job of choosing a model, and in some settings the whole procedure may add little to statistics that can be read off the fitted model directly.
The first limit is variance. Cross-validation is much less biased than re-substitution, the error measured on the very cases used to fit, but a simulation study of microarray classification found that it displays excessive variance, which makes individual estimates unreliable for small samples. The study compared cross-validation, re-substitution and bootstrap estimation for three classifiers, linear discriminant analysis, three-nearest-neighbour and classification trees, on synthetic and real breast-cancer data, and judged them by the distribution of the difference between estimated and true error. Bootstrap methods improved on cross-validation with respect to variance, though at a high computational cost and often with somewhat increased bias, still far below that of re-substitution.[20] The practical consequence is that in a small study a single cross-validation figure may sit some distance from the truth not because the procedure is biased but because it is noisy, and a noisy estimate can rank two models in the wrong order as easily as a biased one.
The second limit concerns model selection rather than error estimation, and it is the more surprising of the two. Leave-one-out cross-validation is asymptotically inconsistent for choosing among linear models: the probability that it selects the model with the best predictive ability does not converge to one as the number of observations grows without bound.[23] The inconsistency can be repaired, but only by a recipe that runs against intuition. Using leave-n_v-out cross-validation, in which the number of observations reserved for validation satisfies n_v/n → 1 as n → ∞, restores consistency, a requirement described as totally opposite to the popular leave-one-out recipe.[23] The finding does not make leave-one-out useless; it marks a boundary. A procedure that is nearly unbiased for estimating the error of a given procedure need not be reliable for picking the best among competing ones, and the two jobs, which were separated at the outset of the method's history, can come apart in practice.
The third dispute is whether cross-validation earns its keep at all in ordinary regression. A detailed study using seven datasets, two standing-tree volume models and a height-diameter model found that fit statistics and lack-of-fit statistics calculated directly from a regression model could be well estimated by simulating cross-validation or double cross-validation. The authors concluded that cross-validation by data splitting and double cross-validation provide little, if any, additional information in the process of evaluating regression models.[24] This is a narrower claim than it may sound. It concerns settings where the model form is fixed and a likelihood or residual structure is available, so that the fit statistics already carry the relevant information; it does not extend to the selection-heavy procedures, the tuned classifiers and the small high-dimensional datasets where the earlier sections found cross-validation doing real work. The dispute is genuine, but it is about the domain of application, not about whether the procedure works.
Running beneath all three is a dependence on protocol details that is easy to overlook because the output is a single number. The estimate shifts with the number of folds, with the number of repetitions, and with the range of candidate values the search was allowed to consider; two protocols that arrive at the same winning model can still yield different nested estimates of its performance, because the two searches incorporated different information into the choice.[3] Reporting a cross-validation error without the protocol that produced it therefore withholds part of what the number means. The remedy is not a better estimator but fuller reporting: the number of folds, the number of repeats, and the grid width and size, so that a reader can judge what was actually measured.
None of these limits overturns the case for cross-validation. They mark where its guarantees are conditional: on a sample large enough for the estimate to be stable, on a selection rule suited to the job of choosing rather than assessing, on a setting where resampling adds information the fit statistics do not already contain, and on a protocol described in enough detail to be interpreted. Where those conditions fail, the honest response is not to abandon the procedure but to say which condition failed, and to treat the resulting number with the caution its provenance deserves.
Key studies
| Year | Study | Sample | Design | Finding |
|---|---|---|---|---|
| 2003 | Hawkins et al.[6] | a large QSAR data set | theoretical argument and empirical study | With samples in the dozens or scores, holding back a test portion is wasteful compared with cross-validation. |
| 2004 | Braga-Neto & Dougherty[20] | synthetic and real breast-cancer patient data | simulation comparing error estimators | Cross-validation was much less biased than resubstitution but showed excessive variance for small samples. |
| 2006 | Varma & Simon[1] | at least 1000 simulated sets of 40 samples with 6000 features each | simulation study of classifier tuning | Tuned classifiers showed errors below 30% on 18.5% and 38% of null sets but did no better than chance on independent data. |
| 2012 | Hijmans[18] | 226 species from six regions | cross-validation study of species distribution models | The null model beat MaxEnt for 45% and Bioclim for 67% of species, showing inflated area under the curve. |
| 2014 | Krstajic et al.[3] | repeated cross-validation experiment | The chosen number of components ranged from 10 to 15 across 50 single cross-validations. | |
| 2016 | Riley et al.[16] | review | Riley, Ensor, Snell, Debray, Altman and Moons report that a systematic review of 78 external validation studies published in 2010 found that 68% of studies did not report evaluating model calibration, and that 46% had fewer than 100 events. | |
| 2017 | Tantithamthavorn et al.[21] | 101 public defect datasets and 18 systems | empirical comparison of validation techniques | Single-repetition holdout gave 46-229% more bias and 53-863% more variance than top techniques. |
| 2020 | Wong & Yeh[11] | 20 data sets | statistical analysis of repeated cross-validation | Accuracy estimates from repeated k-fold runs were generally highly correlated, and more so as folds increased. |
| 2020 | Gerry et al.[13] | 95 articles on early warning scores | systematic review | Recommended approaches such as bootstrapping or cross-validation were used in only 4 of 19 internal validation studies. |
| 2020 | Stafford et al.[4] | 169 studies of machine learning in autoimmune disease | systematic review | Cross-validation combined with a separate testing set occurred in 8.3% of papers. |
| 2021 | Department of Computer Science and Informatics, University of Energy and Natural Resources, Sunyani, Ghana et al.[10] | four algorithms tested on a stroke dataset | empirical comparison of k values | k = 7 gave a slight increase in accuracy and area under the curve for most algorithms. |
| 2023 | Yates et al.[22] | ecological case studies | review with examples | The authors recommend leave-one-out cross-validation, or k-fold with bias correction if k is below 10. |
See also
References
- Varma, S., & Simon, R. (2006). Bias in error estimation when using cross-validation for model selection. BMC Bioinformatics, 7(1). doi:10.1186/1471-2105-7-91
- Vabalas, A., Gowen, E., Poliakoff, E., & Casson, A. J. (2019). Machine learning algorithm validation with a limited sample size. PLOS ONE, 14(11), e0224365. doi:10.1371/journal.pone.0224365
- Krstajic, D., Buturovic, L. J., Leahy, D. E., & Thomas, S. (2014). Cross-validation pitfalls when selecting and assessing regression and classification models. Journal of Cheminformatics, 6(1). doi:10.1186/1758-2946-6-10
- Stafford, I. S., Kellermann, M., Mossotto, E., Beattie, R. M., MacArthur, B. D., & Ennis, S. (2020). A systematic review of the applications of artificial intelligence and machine learning in autoimmune diseases. npj Digital Medicine, 3(1). doi:10.1038/s41746-020-0229-3
- Golub, G. H., Heath, M., & Wahba, G. (1979). Generalized Cross-Validation as a Method for Choosing a Good Ridge Parameter. Technometrics, 21(2), 215-223. doi:10.1080/00401706.1979.10489751
- Hawkins, D. M., Basak, S. C., & Mills, D. (2003). Assessing Model Fit by Cross-Validation. Journal of Chemical Information and Computer Sciences, 43(2), 579-586. doi:10.1021/ci025626i
- TEMPLETON, A. R. (2008). Nested clade analysis: an extensively validated method for strong phylogeographic inference. Molecular Ecology, 17(8), 1877-1880. doi:10.1111/j.1365-294x.2008.03731.x
- Chen, V. B., Arendall, W. B., Headd, J. J., Keedy, D. A., Immormino, R. M., Kapral, G. J., Murray, L. W., Richardson, J. S., & Richardson, D. C. (2010). MolProbity : all-atom structure validation for macromolecular crystallography. Acta Crystallographica Section D Biological Crystallography, 66(1), 12-21. doi:10.1107/s0907444909042073
- Rodriguez, J. D., Perez, A., & Lozano, J. A. (2010). Sensitivity Analysis of k-Fold Cross Validation in Prediction Error Estimation. IEEE Transactions on Pattern Analysis and Machine Intelligence, 32(3), 569-575. doi:10.1109/tpami.2009.187
- Department of Computer Science and Informatics, University of Energy and Natural Resources, Sunyani, Ghana, Nti, I. K., Nyarko-Boateng, O., & Aning, J. (2021). Performance of Machine Learning Algorithms with Different K Values in K-fold CrossValidation. International Journal of Information Technology and Computer Science, 13(6), 61-71. doi:10.5815/ijitcs.2021.06.05
- Wong, T. T., & Yeh, P. Y. (2020). Reliable Accuracy Estimates from k -Fold Cross Validation. IEEE Transactions on Knowledge and Data Engineering, 32(8), 1586-1594. doi:10.1109/tkde.2019.2912815
- Bates, S., Hastie, T., & Tibshirani, R. (2024). Cross-Validation: What Does It Estimate and How Well Does It Do It? Journal of the American Statistical Association, 119(546), 1434-1445. doi:10.1080/01621459.2023.2197686
- Gerry, S., Bonnici, T., Birks, J., Kirtley, S., Virdee, P. S., Watkinson, P. J., & Collins, G. S. (2020). Early warning scores for detecting deterioration in adult hospital patients: systematic review and critical appraisal of methodology. BMJ, m1501. doi:10.1136/bmj.m1501
- Levey, A. S., Stevens, L. A., Schmid, C. H., Zhang, Y. (., Castro, A. F., Feldman, H. I., Kusek, J. W., Eggers, P., Van Lente, F., Greene, T., Coresh, J., & for the CKD-EPI (Chronic Kidney Disease Epidemiology Collaboration)* (2009). A New Equation to Estimate Glomerular Filtration Rate. Annals of Internal Medicine, 150(9), 604-612. doi:10.7326/0003-4819-150-9-200905050-00006
- Brünger, A. T. (1993). Assessment of phase accuracy by cross validation: the free R value. Methods and applications. Acta Crystallographica Section D Biological Crystallography, 49(1), 24-36. doi:10.1107/s0907444992007352
- Riley, R. D., Ensor, J., Snell, K. I. E., Debray, T. P. A., Altman, D. G., Moons, K. G. M., & Collins, G. S. (2016). External validation of clinical prediction models using big datasets from e-health records or IPD meta-analysis: opportunities and challenges. BMJ, i3140. doi:10.1136/bmj.i3140
- Santos, M. S., Soares, J. P., Abreu, P. H., Araujo, H., & Santos, J. (2018). Cross-Validation for Imbalanced Datasets: Avoiding Overoptimistic and Overfitting Approaches [Research Frontier]. IEEE Computational Intelligence Magazine, 13(4), 59-76. doi:10.1109/mci.2018.2866730
- Hijmans, R. J. (2012). Cross‐validation of species distribution models: removing spatial sorting bias and calibration with a null model. Ecology, 93(3), 679-688. doi:10.1890/11-0826.1
- A. Ramezan, C., A. Warner, T., & E. Maxwell, A. (2019). Evaluation of Sampling and Cross-Validation Tuning Strategies for Regional-Scale Machine Learning Classification. Remote Sensing, 11(2), 185. doi:10.3390/rs11020185
- Braga-Neto, U. M., & Dougherty, E. R. (2004). Is cross-validation valid for small-sample microarray classification? Bioinformatics, 20(3), 374-380. doi:10.1093/bioinformatics/btg419
- Tantithamthavorn, C., McIntosh, S., Hassan, A. E., & Matsumoto, K. (2017). An Empirical Comparison of Model Validation Techniques for Defect Prediction Models. IEEE Transactions on Software Engineering, 43(1), 1-18. doi:10.1109/tse.2016.2584050
- Yates, L. A., Aandahl, Z., Richards, S. A., & Brook, B. W. (2023). Cross validation for model selection: A review with examples from ecology. Ecological Monographs, 93(1). doi:10.1002/ecm.1557
- Shao, J. (1993). Linear Model Selection by Cross-validation. Journal of the American Statistical Association, 88(422), 486-494. doi:10.1080/01621459.1993.10476299
- Kozak, A., & Kozak, R. (2003). Does cross validation provide additional information in the evaluation of regression models? Canadian Journal of Forest Research, 33(6), 976-987. doi:10.1139/x03-022
Cite this page: Atlas Nova editors. (2026). Cross-validation. Atlas Nova. https://velocer.io/atlas/cross-validation/