Definition
The paired bootstrap draws rows of the test set with replacement, computes the score of both models on the same draw, and keeps the difference. Repeated a few thousand times, the differences give an interval for the gain of one model over the other.
Δb = scoreA( rowsb ) − scoreB( rowsb )
Because both scores move together from one draw to the next, the hard rows being hard for both models, the difference varies much less than either score. Two intervals that overlap widely can hide a difference that is clearly established.
Worked example
Two scoring models are evaluated on 2,000 test rows. Model B is model A with a little more information. We print the interval of each AUC, then the interval of the paired difference.
import numpy as np
from sklearn.metrics import roc_auc_score
rng = np.random.default_rng(12)
n = 2000
signal = rng.normal(size=n)
y = (signal + rng.normal(scale=1.5, size=n) > 0.8).astype(int)
score_a = signal + rng.normal(scale=1.2, size=n)
score_b = score_a + 0.35 * signal # same model, slightly better informed
auc_a, auc_b, diff = [], [], []
for _ in range(2000):
i = rng.integers(0, n, n)
a, b = roc_auc_score(y[i], score_a[i]), roc_auc_score(y[i], score_b[i])
auc_a.append(a); auc_b.append(b); diff.append(b - a)
ci = lambda v: np.percentile(v, [2.5, 97.5])
print(f"model A: AUC = {roc_auc_score(y, score_a):.3f} 95 % interval [{ci(auc_a)[0]:.3f}, {ci(auc_a)[1]:.3f}]")
print(f"model B: AUC = {roc_auc_score(y, score_b):.3f} 95 % interval [{ci(auc_b)[0]:.3f}, {ci(auc_b)[1]:.3f}]")
print(f"paired difference B - A = {np.mean(diff):+.3f} 95 % interval [{ci(diff)[0]:+.3f}, {ci(diff)[1]:+.3f}]")Output, produced by running the code above when this page was built:
model A: AUC = 0.655 95 % interval [0.631, 0.681] model B: AUC = 0.685 95 % interval [0.662, 0.709] paired difference B - A = +0.030 95 % interval [+0.026, +0.034]
The two intervals overlap, which read alone would suggest no clear winner. The interval of the paired difference excludes zero.
Where it misleads
- The rows must be the right unit. If several rows belong to one client, or one series, resample clients or series, otherwise the interval is too narrow.
- The interval covers the sampling of the test set. It says nothing about the variation from retraining the models with another seed or another training sample.
- A difference that is statistically clear can be too small to matter. The size of the gain is judged against the cost of the more complex model.
- If model B was selected because it beat A on this very test set, the interval is biased, see the sealed test set.
For the AUC, the test of DeLong gives an analytic answer to the same question. For forecast errors in time, the Diebold-Mariano test is the paired comparison.
In our work
We report gains as paired differences with their interval. In our credit validation report the boosting model was 0.060 AUC above the scorecard benchmark, with an interval from +0.049 to +0.071. A paired comparison resolved about ±0.065 in our tests where a level resolved ±0.20.
Service: machine learning and model validation Research note: credit model validation, a worked report Research note: our gates
References
- Efron, B., Tibshirani, R. J. (1993). An introduction to the bootstrap. Chapman and Hall, New York. doi:10.1201/9780429246593
- DeLong, E. R., DeLong, D. M., Clarke-Pearson, D. L. (1988). Comparing the areas under two or more correlated receiver operating characteristic curves: a nonparametric approach. Biometrics, 44(3), 837-845. doi:10.2307/2531595
- Hewamalage, H., Ackermann, K., Bergmeir, C. (2023). Forecast evaluation for data scientists: common pitfalls and best practices. Data Mining and Knowledge Discovery, 37, 788-832. doi:10.1007/s10618-022-00894-5