Tutorials › High-Dimensional Genomic Data Analysis › Uncertainty Intervals for Cross-Validated Performance

Honest Evaluation and Leakage · Tutorial 644 of 795

Uncertainty Intervals for Cross-Validated Performance

Define the uncertainty target, diagnose the limits of naive fold-based standard errors, and construct a cautious bootstrap interval by repeating the complete cross-validation procedure.

Intermediate 12 min read

What You'll Learn

  • Distinguish variation across fold assignments from uncertainty due to sampling new individuals or clusters.
  • Explain why fold losses are dependent and why their standard deviation divided by the square root of the number of folds is not generally a valid standard error.
  • Define the performance target represented by a cross-validated loss estimate.
  • Construct a percentile interval by resampling independent units and rerunning the complete validation pipeline.
  • Account for model tuning, clustered genomic data, and duplicate bootstrap copies when resampling.
  • Interpret bootstrap intervals cautiously and diagnose when the resampling design is unreliable.

What Does an Uncertainty Interval Describe?

A cross-validated loss is an estimate, not a fixed property of a fitted model. Its value depends on the observed sample and on how that sample is divided into folds. An uncertainty interval is useful only after specifying which source of uncertainty it is intended to describe. In genomic prediction, the independent sampling unit might be an individual, a family, or a site, depending on the study design. Treating related individuals as independent can make an interval too narrow even if the cross-validation code is otherwise correct.

Let \(D\) denote the observed data, and let \(\hat L_{\mathrm{CV}}(D)\) denote the cross-validated loss computed using a validation design chosen in advance. The design includes the number and construction of folds, the loss function, any stratification or grouping, and whether hyperparameters are selected within each training set. The earlier material on nested cross-validation establishes why tuning must be repeated inside the training data when the reported performance is intended to account for tuning.

Definition: A cross-validated performance target is the expected loss of a specified learning procedure when trained on data of a specified size and evaluated on new observations from a specified target population. The cross-validation estimate approximates that target using held-out predictions. An uncertainty interval describes uncertainty in the estimate under stated sampling and validation assumptions; it does not, by itself, describe the variation in outcomes for an individual future patient.

This distinction matters because \(K\)-fold cross-validation typically trains each model on about \((K-1)n/K\) observations, not on all \(n\) observations. Its performance estimate therefore most directly concerns the learning procedure at that smaller training size. The final model fitted to all available data may perform differently. The interval also does not automatically cover distribution shifts, such as a change in the genomic cohort or clinical setting.

Why Fold-Based Standard Errors Are Usually Misleading

A tempting calculation is to find the standard deviation of the \(K\) fold losses and divide it by \(\sqrt K\). That formula is a standard error for the mean of \(K\) independent, identically distributed observations with finite variance. Fold losses generally do not satisfy that assumption. Training sets overlap heavily: in ordinary \(K\)-fold cross-validation, two fitted models share much of their training data. Test folds also come from the same original sample, and the fitted models can respond similarly to changes in that sample. Thus the fold losses are dependent, and \(K\) is not the number of independent data sets.

Unequal fold sizes, stratification, clustering, and an irregular loss distribution can add further complications. Even when folds have equal size, a small standard deviation across folds does not establish that the estimated loss would be stable in a new sample. Conversely, a large fold-to-fold spread can reflect which observations happened to be held out, rather than the full sampling uncertainty of interest.

Worked Example: A Naive Fold-Based Interval

Suppose a hypothetical five-fold analysis reports fold losses of 0.42, 0.50, 0.46, 0.54, and 0.48. Assume for this calculation that lower loss is better and all folds have equal size. The mean fold loss is

$$ \bar{L}_{\mathrm{fold}}=\frac{0.42+0.50+0.46+0.54+0.48}{5} =\frac{2.40}{5}=0.480. $$

The squared deviations from 0.480 sum to

$$ (-0.06)^2+(0.02)^2+(-0.02)^2+(0.06)^2+0^2 =0.008. $$

The sample standard deviation of the five fold losses is therefore \(s_{\mathrm{fold}}=\sqrt{0.008/4}=0.04472\), and the naive standard error is \(0.04472/\sqrt{5}=0.02000\). If one then used a \(t\) critical value of 2.776 with \(df=4\), the interval would be

$$ 0.480\ \mathbin{\pm}\ 2.776(0.02000) =(0.4245,\ 0.5355). $$

The arithmetic is correct, but this is not generally a justified confidence interval: its \(t\)-based interpretation requires independent fold losses, which the overlapping training sets do not provide. It is best treated as an illustration of the naive calculation, not as a defensible measure of population-sampling uncertainty.

A Resampling Interval That Repeats the Analysis

A more defensible approach is to resample the independent sampling units and repeat the entire validation procedure in each resample. If individuals are independent, resample individuals. If related individuals or repeated observations form clusters, resample the appropriate clusters instead. The procedure must preserve the original evaluation design: for example, keep families or sites together when the intended validation split keeps them together.

In each bootstrap replicate, rerun all steps that are part of the learning procedure, including fold-local preprocessing, feature selection, and inner-loop tuning where applicable. Reusing the original selected features or tuned hyperparameters would omit their contribution to uncertainty and can make the interval too optimistic. The bootstrap should also reproduce the planned outer-fold design. Where the evaluation target requires stratification or group-aware folds, apply those rules in each replicate.

Procedure: For bootstrap replicate \(b\), draw \(n\) independent sampling units with replacement from the observed units, construct the prescribed folds, rerun the complete cross-validation pipeline, and record its loss \(\hat L_{\mathrm{CV}}^{(b)}\). For a percentile interval with nominal level \(1-\alpha\), use the \(\alpha/2\) and \(1-\alpha/2\) quantiles of the replicate losses. The procedure assumes that the sampled units represent the target population and that the resampling scheme reflects the actual independent units and validation design.

A practical complication is that a bootstrap sample can contain an original individual more than once. Those copies must not be split between training and test folds: otherwise the same person can appear on both sides of a split, creating information leakage. Keep all copies of an original individual in the same fold, and account for their bootstrap multiplicity when computing the replicate loss. If the data are clustered, apply the same principle at the cluster level. A prespecified plan is also needed for replicates in which the desired folds cannot be formed, such as a class being absent from a training fold; silently dropping such replicates changes the resampling distribution.

Worked Example: A Percentile Bootstrap Interval

Consider a hypothetical study with 240 independent participants. The analysis plan uses five-fold outer cross-validation and inner cross-validation to tune a classifier; its reported loss is the prespecified mean across the outer folds. The observed estimate is 0.480. The analysts draw 1,000 bootstrap samples of 240 participants, keep duplicate copies of each participant together when assigning folds, and rerun the complete nested pipeline in every replicate.

Suppose the 25th ordered replicate loss is 0.431 and the 975th is 0.529. With 1,000 replicates, these approximate the 2.5th and 97.5th percentiles. The percentile interval is therefore \((0.431,\ 0.529)\). In context, this is an approximate 95% interval for the cross-validated loss of the specified learning and validation procedure under the assumed participant-sampling process. It is not a 95% probability statement about the fixed, unknown loss, and it is not a guarantee about performance in a different population.

The interval is only as credible as the resampling design. If participants are related, resampling 240 people independently would fail to preserve the dependence; family-level resampling may be needed instead. If the classifier was tuned, failing to repeat the tuning inside each replicate would not represent the full procedure. A percentile interval also does not correct bias caused by an unsuitable validation design or leakage in the original analysis.

Justification and Interpretation

The logic of the bootstrap is to approximate how the estimator would vary across repeated samples from the target population. The empirical distribution of the observed independent units is used as a stand-in for that population. Resampling from it creates datasets with variation in which units are present and how often they appear. Rerunning the complete analysis maps that data variation through the same procedure used to calculate the reported estimate.

1
Specify the target and independent unit.
State the loss, target population, training-size interpretation, and whether the independent unit is a person, family, site, or another cluster.
2
Resample at that unit.
Draw bootstrap samples with replacement, preserving any sampling or grouping structure needed for the target.
3
Repeat the full pipeline.
Rebuild folds and refit every training-dependent step, including tuning, for each replicate.
4
Summarize replicate estimates.
Use the chosen quantiles as an approximate interval, and report the resampling unit, replicate count, and validation design.

This justification is approximate, not an exact coverage theorem for every cross-validation estimator. It relies on the empirical distribution adequately representing the target population and on the estimator behaving regularly enough for resampling to approximate its sampling distribution. Small samples, rare outcomes, highly unstable feature selection, or few independent clusters can undermine that approximation. Increasing the number of bootstrap replicates reduces Monte Carlo error in estimated quantiles, but it does not create more independent information or repair a poor design.

Worked Example: Split Variation Is Not a Sampling Interval

Suppose five repetitions of cross-validation on the same hypothetical dataset produce losses 0.463, 0.471, 0.480, 0.489, and 0.497. Their mean is 0.480. Their sample standard deviation is

$$ s_{\mathrm{split}} =\sqrt{\frac{(-0.017)^2+(-0.009)^2+0^2+(0.009)^2+(0.017)^2}{4}} =\sqrt{\frac{0.000740}{4}} =0.01360. $$

This describes how much the estimate varied across these five random split schedules on this one dataset. It does not estimate how much the result would vary if a new sample of participants were collected. Repeating cross-validation more times can make the average less sensitive to the particular random splits, but it cannot substitute for resampling independent sampling units when the goal is sampling uncertainty.

Diagnostics, Alternatives, and Limitations

Before reporting an interval, check whether the resampling procedure actually matches the scientific sampling process. Examine whether replicates preserve family, site, or other dependence; whether every replicate can form valid folds; and whether the entire tuned pipeline was rerun. Inspect the bootstrap distribution for skewness, extreme values, or multiple modes. These features may signal a genuinely unstable analysis, sparse outcomes, or a resampling scheme that is poorly suited to the data. Report the number of failed or modified replicates and how they were handled.

The main alternatives answer different questions. A fold-based standard error is simple but generally lacks a sound independence justification. Repeated cross-validation summarizes sensitivity to random splits conditional on the observed sample. A bootstrap that reruns cross-validation targets sampling variation under its resampling assumptions, while an external validation sample directly assesses performance in that sample and population but may itself have substantial sampling uncertainty. None of these approaches automatically accounts for population shift or repairs leakage.

A common mistake is to treat the \(K\) fold losses as \(K\) independent observations and report their standard deviation divided by \(\sqrt K\) as the standard error. The correction is to recognize that folds share training data and come from one dataset. Define the uncertainty target, resample the actual independent units, and rerun the full procedure when sampling uncertainty is the goal. If there are very few independent clusters or the bootstrap distribution is erratic, report that limitation rather than implying precise coverage.

Key takeaway: An uncertainty interval for cross-validated loss depends on the target, the independent sampling unit, and the full validation procedure. A unit-level bootstrap that repeats the complete analysis is often more defensible than a naive fold-based standard error, but its coverage remains approximate and assumption-dependent.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions.

  1. Why is the standard deviation of \(K\) fold losses divided by \(\sqrt K\) not generally a valid standard error?
  2. A genomic dataset contains sibling pairs, and the intended validation design keeps siblings in the same fold. What should be resampled for a sampling-uncertainty interval?
  3. In a bootstrap replicate, the same participant is sampled three times. Why should those copies not be placed in different folds?
  4. What kind of uncertainty is summarized by the spread of repeated cross-validation estimates on one fixed dataset?
  5. Does a 95% bootstrap percentile interval guarantee 95% coverage for performance in a new hospital cohort? Explain.

Solutions. (1) The fold losses are dependent because their training sets overlap and they come from the same observed sample, so the independent-observation standard-error formula is not justified. (2) Resample sibling pairs, or the relevant family clusters if families contain more related individuals, so the resampling unit reflects dependence and the planned grouping. (3) Splitting copies across folds could put the same participant in training and test data, causing leakage; keep all copies of an original participant together and respect their bootstrap multiplicity. (4) It summarizes sensitivity to random fold assignments conditional on that dataset, not sampling uncertainty across newly collected datasets. (5) No. The interval is approximate under its resampling assumptions for the specified target population and procedure; a new hospital cohort may differ in population or setting, and external validation is needed to assess that change.

Clinical Biostats