Contents
Cross-Validation/Chapter 09 of 09
09Summary
- Training accuracy lies: 1-nearest neighbor scores 100\% on its training data and 87.7\% on new patients. Optimism =\frac2N\sum_i\Cov(\hat y_i,y_i), which is 2\sigma^2/k for k-nearest neighbors with N/k effective parameters; training error always picks the most flexible model.
- One split is a coin flip: \Var(\hat p)=\frac{p(1-p)}{n}\frac{N-n}{N-1}; the same model on 200 splits scored 83.3\% to 96.5\%, while good candidates differ by about one point.
- K-fold cross-validation: \mathrm{CV}(\lambda)=\frac1K\sum_jR(\hat\theta_\lambda(\D_{-j}),\D_j); every training point is validated once; 404 of 455 correct, 88.8\%, and 6.7 times steadier than one validation split. Use K=5 or 10, stratified.
- Tune, then refit: same folds for every candidate, pick the best, refit once, test once: MK+1=51 trainings; k=41, \mathrm{CV} 90.1\%, test 93.0\%. One-standard-error rule: k=61. Honest estimate after tuning: a locked test set or nested cross-validation, K_{\text{out}}(MK_{\text{in}}+1) trainings.
- Leave-one-out for least squares: y_i-\hat y_i^{(-i)}=(y_i-\hat y_i)/(1-h_{ii}), one fit instead of N.
- No leaks: every step that learns from data goes inside the folds. Selecting features on all the data turned pure noise into 1\% error; inside the folds, 49.6\%. Group by patient, and validate time series on the future.