Why Model Selection Needs Its Own Evaluation
In multi-omics prediction, a modeling strategy is rarely fixed in advance. Analysts may compare integration strategies, feature-selection rules, regularization strengths, or other settings. Each choice can use information in the observed outcomes. If the same cross-validation results both select the best-performing procedure and estimate its performance, the estimate tends to be optimistic: random features of the data have helped determine which result is reported.
Nested cross-validation separates these tasks. An inner loop chooses among candidate procedures using only the current training data. An outer loop evaluates the procedure produced by that choice on held-out data. The target is the performance of the whole selection process, not the performance of a model whose settings were fixed using information from the held-out cases.
The independent unit for splitting must match the prediction target. For example, if predictions concern new patients, related samples from one patient must not be split across training and test data. If the target is prediction in a new cohort, random individual-level splitting may not answer the question; a cohort-aware design may be needed. The earlier material on choosing independent units and cohort-aware splits supplies this design principle.
Constructing the Two Loops
Let the \(n\) independent units be partitioned into \(K\) outer folds \(I_1,\ldots,I_K\). For outer fold \(k\), the outer test set is \(I_k\), and the outer training set contains all units not in \(I_k\). Let \(\lambda\) denote a candidate procedure: it may specify an integration strategy and settings such as a regularization strength. It is the complete candidate to be compared, not just a single numerical setting.
Within each outer training set, divide the data into inner folds. For each candidate \(\lambda\), fit it on each inner training portion and evaluate it on the corresponding inner validation portion. Aggregate those validation results according to a prespecified metric and selection rule. For a loss to be minimized, the choice can be written as:
Here \(\Lambda\) is the set of candidates, and \(\widehat{L}_{\mathrm{inner},k}(\lambda)\) is the inner-loop estimate of loss for candidate \(\lambda\) within outer training set \(k\). For a metric to be maximized, such as a prespecified discrimination measure, use the corresponding maximization rule. Ties require a rule stated in advance, such as choosing the simpler candidate.
After choosing \(\hat{\lambda}_k\), fit that procedure using the entire outer training set and predict outcomes for the outer test fold. Each unit therefore receives an outer prediction from a fit that did not use its outcome for tuning or fitting. Any data-adaptive operation used in a candidate procedure must respect the inner training and validation boundaries while candidates are compared. The later material on fold-local preprocessing and feature selection addresses those operations in detail; nesting does not make it acceptable to use validation outcomes during fitting.
Set aside its outcomes and predictors for evaluation. Do not use this fold to select the candidate procedure.
Run inner cross-validation on that set, compare the prespecified candidates, and select one by the stated rule.
Fit the selected procedure on the full outer training set, predict the outer test fold, and calculate the chosen metric.
Repeat for every outer fold and combine the outer results in a way that matches the performance target and metric.
What the Outer Results Estimate
Suppose the prediction target is a loss \(L\), with smaller values preferred. If \(L_k\) is the loss on outer fold \(k\), the unweighted mean of fold losses is:
This is a direct summary when folds have equal size. With unequal fold sizes and a per-observation loss, a size-weighted average is often appropriate:
where \(n_k\) is the number of observations in outer fold \(k\). For non-additive metrics, such as area under the receiver operating characteristic curve (AUC), the mean of fold-specific values and a metric computed from all outer predictions are not generally equivalent. In particular, pooling scores from separately fitted models can compare scores on different scales across folds. Choose and report the summary that matches the intended estimand; do not silently treat these summaries as interchangeable.
The outer estimate concerns the selection-and-fitting procedure trained on roughly the outer training-set size, not necessarily a final model trained on all \(n\) observations. Its relevance depends on the folds representing the intended deployment population and on the data-generating conditions being sufficiently similar. Cross-validation does not by itself establish transportability to a different population.
Worked Example: Selecting a Regularization Strength in the Inner Loop
Suppose an outer training set contains 60 hypothetical patients with two omics blocks. The prespecified candidate procedures use the same integration strategy but differ in regularization strength, \(\lambda=0.1\) or \(\lambda=1\). Four inner folds give the following validation mean squared errors (MSE), in squared standardized-outcome units.
| Candidate | Inner-fold MSEs | Mean inner MSE |
|---|---|---|
| \(\lambda=0.1\) | 0.90, 1.10, 1.00, 1.00 | 1.00 |
| \(\lambda=1\) | 0.80, 0.90, 0.90, 1.00 | 0.90 |
The means are calculated as \((0.90+1.10+1.00+1.00)/4=1.00\) and \((0.80+0.90+0.90+1.00)/4=0.90\). Since MSE is a loss, choose the candidate with smaller mean: \(\hat{\lambda}=1\). Fit that candidate on all 60 outer-training patients, then evaluate it on the outer test fold. The inner value 0.90 is not the outer performance estimate; it was used to select the candidate.
Worked Example: Calculating Outer-Fold MSE
For one hypothetical outer test fold of four patients, a selected multi-omics procedure produces standardized-outcome predictions with residuals \(0.2,-0.4,0.1,-0.3\). Its fold MSE is the mean squared residual:
Thus this fold's estimated squared prediction error is \(0.075\) squared standardized-outcome units. It is not a measure of error in the original clinical units because the outcome here was standardized. The calculation is valid as an outer evaluation only if these patients' outcomes did not influence the inner selection, fitting, or any other data-adaptive decision used to produce their predictions.
Worked Example: Summarizing Three Outer Folds
A hypothetical three-fold outer evaluation yields MSEs of \(0.64\), \(0.81\), and \(0.49\) squared standardized-outcome units, with four patients in each fold. Since the folds are equal in size, the mean outer MSE is:
The procedure's average outer-fold MSE is \(0.647\) squared standardized-outcome units for these splits. The fold losses vary from \(0.49\) to \(0.81\), so reporting only the mean would hide some split-to-split variation. This range is descriptive, not a confidence interval. Outer folds have overlapping training sets, so treating the three fold values as independent observations and using their standard deviation divided by \(\sqrt{3}\) as a generally valid standard error is not justified.
Why Reusing the Outer Results Creates Optimism
The outer folds protect the evaluation from decisions made inside each outer training set. But that protection is lost if the analyst uses the outer results to make another selection and then reports the selected result as unbiased. For example, comparing five integration strategies by their outer AUCs and reporting only the largest AUC uses outer performance to choose the winner. The reported maximum is favored partly because it may have benefited from favorable sampling variation.
The basic reason is the maximum's tendency to exceed the average when estimates vary. If \(Z_1,\ldots,Z_m\) are noisy estimates of equally good candidates, then:
This inequality does not quantify the amount of optimism, but it shows why selecting the largest noisy estimate is not a neutral reporting step. To estimate performance after choosing among strategies, include those strategies in the inner selection process and evaluate that selection process in the outer loop. Alternatively, use a genuinely untouched test set for the final evaluation. Outer-fold results can still compare prespecified procedures, but choosing a winner from those results changes what can be claimed about that winner's performance.
Worked Example: A Winner Chosen From Outer AUCs
Consider three hypothetical candidate strategies with mean outer AUCs \(0.78\), \(0.81\), and \(0.79\). If the strategies were prespecified and all three results are reported, these are outer-CV summaries for their respective procedures. If the analyst instead selects the strategy with AUC \(0.81\) because it is the largest and presents \(0.81\) as an unbiased estimate for the selected winner, the interpretation is not warranted: the outer results have now been used for selection.
A valid design for estimating the performance of this choice would make the three strategies inner-loop candidates within each outer training set. Each outer fold would then evaluate whichever strategy the inner loop selected. The resulting outer AUCs would estimate the performance of the selection rule, not guarantee that the same strategy wins in every fold or that a final all-data fit will have exactly that AUC.
Assumptions, Diagnostics, and Alternatives
Nested cross-validation is useful only when its design matches the question. Its interpretation relies on several practical conditions:
- Splits respect independent units. Replicates, repeated measurements, or related samples that could share information must be kept together when the deployment target is a new independent unit.
- Outer folds represent the target population. If deployment is to new cohorts, sites, or time periods, folds should reflect that target rather than merely randomize individuals across all sources.
- Selection is contained in the inner loop. Candidate comparisons and data-adaptive choices must not use outer-test outcomes. The candidate set and metric should be specified without inspecting outer results to decide what to report.
- Each split permits fitting. Training folds must contain enough observations and relevant outcome classes for the chosen procedures and metrics. A fold with no positive cases, for example, cannot supply a meaningful sensitivity or AUC estimate.
Check fold sizes and outcome distributions before fitting. Record which candidate is selected in each outer fold; frequent changes can indicate unstable selection even when average performance looks adequate. Compare outer-fold metrics for unusual variation, and investigate whether it aligns with cohort, site, class composition, or fold size. Also verify that the inner loop is run separately within each outer training set. Running one global tuning exercise and carrying its chosen setting into every outer fold defeats the separation.
A single held-out test set is an alternative when there is enough data to reserve a representative test sample and the modeling decisions can be completed using the remaining training data. It offers a direct final evaluation but may be imprecise, especially with small samples. Non-nested cross-validation can be suitable for evaluating a fully prespecified procedure whose settings are not chosen from those same validation results. It does not, on its own, remove the optimism caused by selecting the best candidate using the same cross-validation scores later reported as performance.
Nested cross-validation also has limits. Its outer estimate is noisy in small samples, results depend on the split design, and its training sets are smaller than the full data set. Repeating the nested design can show sensitivity to random partitions, but repeated results are not independent replications of the study. Finally, no resampling design fixes a mismatch between the observed data and the deployment population.
Check Your Understanding
Answer each question, then compare with the solutions.
- In one outer fold, where may the regularization strength be chosen, and which data are used for the final fit before outer testing?
- Why is the best of several outer-fold AUCs not automatically an unbiased performance estimate for the selected strategy?
- Three equal-sized outer folds have MSEs \(0.30\), \(0.45\), and \(0.60\). Calculate their mean MSE.
- What is wrong with putting samples from the same patient in different folds when the goal is prediction for new patients?
- Why should the standard deviation of outer-fold scores divided by the square root of the number of folds not automatically be called a standard error?
Solutions. (1) Choose the strength in the inner loop using only the outer training set; then fit the selected procedure on that entire outer training set before predicting the outer test fold. (2) Choosing the largest outer AUC uses the evaluation results for selection, so favorable sampling variation can help determine the reported winner. (3) \((0.30+0.45+0.60)/3=1.35/3=0.45\) squared outcome units. (4) Related samples can share patient-specific information across training and test sets, making the evaluation unlike prediction for a new patient. (5) Outer-fold training sets overlap, so fold scores are generally dependent and the usual independent-sample standard-error calculation is not automatically valid.