Why the Aggregation Rule Matters
In cross-validation, each held-out observation receives a prediction from a model that did not use that observation for fitting. After the folds have been evaluated, there are two common summaries: pool the out-of-fold predictions and calculate one metric, or calculate a metric within each fold and average those fold metrics. These summaries do not always answer the same question.
For accuracy and per-observation loss, the difference is usually a weighting choice: pooling gives each observation equal weight, while a simple average gives each fold equal weight. AUC is more delicate. A pooled AUC compares scores from observations in different folds, even though those scores came from different fitted models. A fold-average AUC does not make those cross-fold comparisons.
The distinction matters in genomic prediction, where folds may differ in size, class balance, cohort composition, or the scale of model scores. A reported performance number should make clear both the metric and the aggregation rule used to obtain it.
Setup and Definitions
Suppose a binary outcome \(y_i\) is recorded for each of \(n\) observations. Each observation belongs to one held-out fold \(k(i)\), and \(\hat p_i^{(-k)}\) denotes its predicted probability of the positive outcome from the model fitted without fold \(k\). Write \(s_i\) for a prediction score used to rank observations. If a predicted class is needed for accuracy, use a fixed threshold \(\tau\): the predicted class is positive when \(\hat p_i^{(-k)}\geq\tau\), and negative otherwise. The threshold is treated as already specified, not selected from these held-out outcomes.
This setup presumes that each observation has one out-of-fold prediction, that the outcome and prediction are paired to the same observation, and that all data-dependent preprocessing and model fitting were confined to the corresponding training data. The fold design must also respect the intended evaluation unit: for example, related individuals or samples that must be kept together should not be split across training and held-out folds. These conditions make the predictions suitable for evaluation; they do not guarantee that every fold metric is stable or that folds represent the eventual target population.
For accuracy, let \(a_k\) be the number of correct classifications among the \(n_k\) observations in fold \(k\). The fold accuracy is \(A_k=a_k/n_k\). Pooled accuracy is the total number correct divided by the total number of observations. These two definitions already show why fold sizes matter.
Thus, pooled accuracy is the fold-size-weighted mean of fold accuracies. It equals the unweighted fold mean when fold sizes are equal, or in special cases where the fold accuracies happen to make the two averages equal. The same weighted-average identity applies to any loss that is calculated per observation and then averaged.
Worked Examples
Worked Example: Pooled Accuracy and Unequal Fold Sizes
Consider two hypothetical held-out folds. In fold 1, four observations produce three correct classifications. In fold 2, six observations produce three correct classifications. The same fixed classification threshold is applied in both folds.
The fold accuracies are \(A_1=3/4=0.75\) and \(A_2=3/6=0.50\). Their unweighted mean is \( (0.75+0.50)/2=0.625\), or 62.5%.
Pooling counts gives six correct classifications among ten observations: \(A_{\mathrm{pooled}}=(3+3)/(4+6)=6/10=0.60\), or 60.0%. The fold-size-weighted calculation agrees: \( (4/10)(0.75)+(6/10)(0.50)=0.30+0.30=0.60\).
The two percentages are not contradictory. The unweighted mean gives each fold half the influence, despite their different sizes. The pooled result gives each of the ten observations equal influence. If the folds had represented sites and the target question gave each site equal importance, an unweighted fold summary could be relevant—but that would be a different target summary and should be labelled accordingly.
For binary outcomes, empirical AUC can be defined as the proportion of positive-negative pairs in which the positive observation has the higher score, counting a tied pair as one-half. If fold \(k\) contains \(n_{k+}\) positives and \(n_{k-}\) negatives, it contributes \(n_{k+}n_{k-}\) such pairs to its fold AUC.
A pooled AUC uses the same pairwise rule but compares every positive observation with every negative observation, including pairs drawn from different folds. Consequently, it is not generally an average of the fold AUCs. Even a pair-count-weighted average of fold AUCs includes only within-fold pairs, whereas pooled AUC also includes cross-fold pairs.
Worked Example: Pooled AUC Adds Cross-Fold Comparisons
Suppose there are two hypothetical folds, each containing one positive and one negative observation. In fold 1, their scores are 0.60 for the positive and 0.50 for the negative. In fold 2, their scores are 0.90 for the positive and 0.80 for the negative.
Within each fold the positive score exceeds the negative score, so each fold AUC is \(1/1=1.00\), and the unweighted mean fold AUC is 1.00.
For pooled AUC there are four positive-negative pairs. The fold 1 positive (0.60) beats the fold 1 negative (0.50), but not the fold 2 negative (0.80). The fold 2 positive (0.90) beats both negatives. Thus three of four comparisons are wins: \(\mathrm{AUC}_{\mathrm{pooled}}=3/4=0.75\).
No within-fold ranking was imperfect. The reduction arises entirely because the pooled calculation compares scores produced by different fitted models. If fold-specific score scales are not comparable, that extra comparison may not describe the ranking performance one intended to assess.
For a per-observation loss, let \(\ell_i=\ell(y_i,\hat p_i^{(-k)})\). The fold mean loss is \(L_k=(1/n_k)\sum_{i:k(i)=k}\ell_i\); the pooled mean loss is the average over all observations. Log loss is one example, defined for binary outcomes by \(-y_i\log(\hat p_i^{(-k)})-(1-y_i)\log(1-\hat p_i^{(-k)})\). Smaller values indicate predictions that assign greater probability to the observed outcomes, with large penalties for confident errors.
Worked Example: Pooled Log Loss Versus the Fold Mean
In a hypothetical two-fold evaluation, fold 1 has two observations: one positive with predicted probability 0.80 and one negative with predicted probability 0.30. Fold 2 has four observations: two positives each predicted at 0.90 and two negatives each predicted at 0.20. Use natural logarithms.
The fold 1 losses are \(-\log(0.80)=0.2231\) and \(-\log(1-0.30)=-\log(0.70)=0.3567\). Its mean loss is \((0.2231+0.3567)/2=0.2899\).
In fold 2, each positive has loss \(-\log(0.90)=0.1054\), and each negative has loss \(-\log(1-0.20)=-\log(0.80)=0.2231\). The fold mean is \([2(0.1054)+2(0.2231)]/4=0.1643\).
The unweighted fold mean is \((0.2899+0.1643)/2=0.2271\). Pooling the six observation-level losses instead gives \([0.2231+0.3567+2(0.1054)+2(0.2231)]/6=1.2368/6=0.2061\). The pooled result is also the fold-size-weighted mean: \((2/6)(0.2899)+(4/6)(0.1643)=0.2062\), with the small difference from 0.2061 due to rounding intermediate values. Both summaries are valid, but one weights observations equally and the other weights folds equally.
Why the Summaries Differ
The accuracy and loss identities follow from partitioning a sum by fold. For any per-observation quantity \(q_i\), define the fold mean \(\bar q_k=(1/n_k)\sum_{i:k(i)=k}q_i\). Then \(\sum_i q_i=\sum_k\sum_{i:k(i)=k}q_i=\sum_k n_k\bar q_k\). Dividing by \(n=\sum_k n_k\) gives the pooled mean as \(\sum_k(n_k/n)\bar q_k\). An unweighted fold mean instead assigns coefficient \(1/K\) to every fold. This proves the weighting distinction without relying on a particular loss formula.
AUC is not a per-observation mean: it is a mean over positive-negative pairs. The pooled set of pairs contains both within-fold and cross-fold comparisons. Also, a simple mean of fold AUCs weights folds equally even when their numbers of positive-negative pairs differ. A pair-count-weighted average of fold AUCs weights the within-fold pairs equally, but still does not reproduce pooled AUC unless there are no cross-fold pairs or their contribution happens to match the within-fold result.
Choosing and Reporting a Summary
| Metric | Pooled out-of-fold summary | Average fold summary | Main interpretive issue |
|---|---|---|---|
| Accuracy | Correct observations divided by all observations | Mean of fold-specific proportions | Observation-weighted versus fold-weighted result |
| Per-observation loss | Total loss divided by all observations | Mean of fold mean losses | Observation-weighted versus fold-weighted result |
| AUC | Ranks all positive-negative pairs, including cross-fold pairs | Mean of within-fold AUCs | Cross-fold score comparability and fold weighting |
For accuracy or loss, use pooled evaluation when the intended summary is average performance per observation in the combined held-out sample. Use an unweighted fold mean when the intended summary gives each fold equal importance, for example when folds deliberately represent distinct sites and the target question concerns a typical site rather than a typical observation. Neither rule is universally preferable; the estimand and fold design determine the choice.
For AUC, a mean of fold AUCs has a direct interpretation as average within-fold ranking performance, subject to the chosen fold weighting. Pooled AUC instead describes ranking across the combined out-of-fold scores, including comparisons between models' score outputs. Such comparisons are most defensible when the score scales are meaningfully comparable across folds. If each fitted model can produce scores on a different scale, report fold AUCs or their clearly specified average rather than implying that pooled cross-fold comparisons are automatically meaningful.
A transparent report names the aggregation rule, gives fold sizes and relevant class counts, and states whether AUC is pooled or averaged across folds. If both summaries are useful, report both with their interpretations rather than selecting whichever looks better. In repeated cross-validation, the same observation may receive several held-out predictions; the analyst must additionally state how repeats were combined before calculating a metric. A single-prediction pooling identity cannot be applied without specifying that step.
Diagnostics and Common Pitfalls
- Assuming a simple fold average is pooled performance. This is false for unequal fold sizes. Check the fold sizes and compare the unweighted average with the size-weighted calculation.
- Interpreting pooled AUC as only within-fold ranking. It includes cross-fold pairs. Inspect fold-specific score distributions and determine whether scores from separate fitted models are comparable.
- Ignoring class counts. A fold without both outcome classes has no defined empirical AUC. Very small positive or negative counts also make a fold AUC based on few pairs and potentially unstable.
- Comparing summaries built from different predictions. Confirm that both calculations use the same held-out observations and the same out-of-fold predictions. Do not refit or preprocess using held-out outcomes to make one summary appear more favorable.
- Changing the target implicitly. Equal weighting of sites, folds, and individuals are distinct choices. State which units receive equal weight and why that matches the intended application.
These metrics remain estimates based on a particular validation design. They can be sensitive to the fold assignment, and the folds may not represent future cohorts or sites. Aggregation cannot repair leakage, an inappropriate split, or a mismatch between the validation population and intended use. For uncertainty, retain the validation design and its dependencies in view rather than treating individual fold results as automatically independent observations.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions below.
- Two folds have sizes 5 and 15, with accuracies 0.80 and 0.60. Calculate pooled accuracy and the unweighted fold mean.
- Why can the pooled AUC differ from the average fold AUC even when every fold AUC is 1.00?
- Fold mean losses are 0.30 and 0.10, from folds of sizes 2 and 8. Find the pooled mean loss and the unweighted fold mean.
- A fold contains positive observations but no negative observations. Can its empirical AUC be calculated? Explain.
- What must be checked before interpreting pooled AUC from out-of-fold predictions?
Solutions. (1) Pooled accuracy is \((5/20)(0.80)+(15/20)(0.60)=0.20+0.45=0.65\). The unweighted fold mean is \((0.80+0.60)/2=0.70\). (2) Pooled AUC compares positives and negatives across different folds as well as within each fold; cross-fold comparisons can be losses if score scales differ. (3) Pooled loss is \((2/10)(0.30)+(8/10)(0.10)=0.06+0.08=0.14\). The unweighted mean is \((0.30+0.10)/2=0.20\). (4) No. AUC requires positive-negative pairs, and this fold has no such pairs. (5) Check that the same leakage-safe out-of-fold predictions are used and consider whether scores from different fold-specific models have comparable scales; also report the fold class counts and aggregation rule.