Cross-validation Confidence Intervals for Test Error

Pierre Bayle, Alexandre Bayle, Lucas Janson, Lester Mackey

TL;DR

While cross-validation (CV) is the standard method for evaluating predictive models, quantifying its uncertainty has historically relied on flawed heuristics or overly loose bounds. This paper establishes central limit theorems (CLTs) for $k$-fold CV and introduces the first consistent estimators of its asymptotic variance under mild algorithmic stability conditions. The result is a practical framework for computing asymptotically exact confidence intervals and powerful, theoretically valid hypothesis tests for model comparison—even for leave-one-out CV.

What Problem Does This Paper Address?

Practitioners routinely use $k$-fold CV to estimate out-of-sample test error. However, constructing confidence intervals (CIs) or testing whether Model A outperforms Model B is notoriously difficult because CV fold errors are interdependent: training sets overlap, and training points in one fold appear as test points in another.

Standard statistical tests (such as the cross-validated $t$-test, repeated train-validation splits, or $5 \times 2$ CV) ignore or heuristically patch over this dependence, leading to invalid inferences and severe undercoverage. Conversely, non-asymptotic concentration inequalities produce CIs that are often orders of magnitude too wide to be useful. Prior attempts at establishing CV CLTs either made restrictive assumptions (e.g., bounded losses, loss-consistency to a deterministic rule) or failed to provide a consistent variance estimator needed to construct operational CIs and tests.

Methods

The authors prove that under an asymptotic linearity condition, the normalized difference between the $k$-fold CV error $\hat{R}_n$ and the true $k$-fold test error $R_n$ converges to a standard normal distribution: $$\frac{\sqrt{n}}{\sigma_n} (\hat{R}_n - R_n) \xrightarrow{d} \mathcal{N}(0, 1)$$

To make this practical, the authors contribute:

  1. Sufficient Stability Conditions: They show that asymptotic linearity holds if the learning algorithm satisfies mild loss stability ($\gamma_{\text{loss}}(h_n) = o(\sigma_n^2 / n)$) or conditional variance convergence. This accommodates non-convex losses, randomized learners (like random forests), and asymmetric training algorithms (like stochastic gradient descent).
  2. Two Consistent Variance Estimators:
  3. Within-fold estimator ($\hat{\sigma}_{n,\text{in}}^2$): A sample variance of losses calculated within each validation fold (valid for $k < n$).
  4. All-pairs estimator ($\hat{\sigma}_{n,\text{out}}^2$): A sample variance taken across all individual point predictions against the overall CV error. This accommodates any choice of $k$, providing the first consistent variance estimator for leave-one-out CV (LOOCV, $k=n$).
  5. Inference Procedures: Both estimators run in $O(n)$ time (or $O(1)$ for binary 0–1 loss) and enable asymptotically exact $(1-\alpha)$ CIs as well as valid one-sided hypothesis tests for algorithmic comparison.

Datasets

The authors evaluated their methodology across varying training sample sizes ($n \in [700, 11\,000]$) subsampled from two real-world benchmarks:

  • Higgs dataset: Binary classification using $\ell_2$-regularized logistic regression, neural networks, and random forests.
  • Kaggle FlightDelays dataset: Regression using ridge regression, neural networks, and random forests.

Ground-truth test error was approximated using large held-out test splits from the full datasets. No new datasets were introduced.

Key Insights and Ideas

  • Asymptotic Linearity via Loss Stability: You do not need independent validation sets to obtain asymptotic normality. It is sufficient that changing one training point produces an average squared shift in out-of-sample loss that decays as $o(\sigma_n^2 / n)$.
  • Smaller Asymptotic Variance: The asymptotic variance parameter $\sigma_n^2$ in this CLT is strictly smaller than or equal to the variance parameter derived in competing recent work (Austern & Zhou, 2020), which can become infinite even when the authors' variance parameter remains finite and valid.
  • Concentration Inequalities vs. CLTs: Non-asymptotic concentration intervals are brutally conservative. In ridge regression experiments, the tightest existing concentration-based interval was 91 times wider than the CLT interval on standardized features, and $5 \times 10^{14}$ times wider on unstandardized features.
  • Stability is Relative: Instability is most hazardous when comparing two very similar algorithms, because the noise parameter $\sigma_n^2$ becomes small. For single-algorithm performance estimation, $\sigma_n^2$ is larger, making CIs robust even for less-regularized models.

Key Results

  • Exact Coverage: For 95% CIs, the proposed CV CLT intervals reliably delivered near-95% coverage across all sample sizes. In contrast, standard repeated train-validation intervals severely undercovered (often dropping to 80–85%).
  • Narrowest Widths: The valid single train-validation split (hold-out) baseline produced substantially wider intervals, whereas the proposed CLT intervals consistently achieved the narrowest interval widths across all dataset sizes.
  • Highest Hypothesis Testing Power: When testing if one algorithm improves upon another at level $\alpha = 0.05$, the CLT-based test maintained valid size ($\le 0.05$) while systematically achieving the highest statistical power among all valid alternatives.
  • Practical LOOCV: Paired with the Sherman–Morrison–Woodbury formula for ridge regression, the all-pairs estimator $\hat{\sigma}_{n,\text{out}}^2$ enabled valid LOOCV confidence intervals that matched 10-fold CV precision without empirical breakdown.

Limitations and Future Work

  • Inferential Target is Conditional: The CLT applies to the $k$-fold test error $R_n$ (the average test error of the $k$ specific prediction rules trained on the data splits), rather than the expected generalization error across arbitrary draws of training datasets, $\mathbb{E}[R_n]$.
  • Requires Algorithm Stability: When algorithms are deliberately destabilized (e.g., deep unregularized trees or unpenalized neural networks), the variance condition is violated and the hypothesis test's false positive rate exceeds the nominal significance level. Developing valid inference under heavy instability remains an open challenge.
  • Assumes Independent Data: The primary theorems assume i.i.d. observations (extended to independent, non-identically distributed data in the appendix), excluding correlated settings such as time series or spatial data.

Summary updated

BibTeX
@inproceedings{bayle2020cross,
  author = {Pierre Bayle and Alexandre Bayle and Lucas Janson and Lester Mackey},
  title = {{Cross-validation Confidence Intervals for Test Error}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2020},
  url = {https://openreview.net/forum?id=AeY7TnmNY10},
}
Figure