Evaluating Model Performance

The Data Science unit on judging a model by data it has not seen. The bias-variance decomposition of expected error, the measures for classifiers and the loss functions for probabilities and for numerical predictions, the division of data into training, validation and test sets, cross-validation and the bootstrap as resampling estimates of prediction error, and the choice among candidate models by penalized criteria and by cross-validation, worked on a diabetes study and breast cancer biopsies with seeded experiments.

A model is only as good as the evidence that it works on data it has not seen. A fitted model looks better on the cases it was fitted to than it will on the next case, and the gap grows with its flexibility. This unit is about measuring that gap and acting on it: what the expected error of a prediction consists of, how to score classifiers and regression models, how to divide data so that a score is honest, how resampling estimates error when data are scarce, and how to choose among candidate models without rewarding complexity for its own sake.

The running examples are two public datasets. The diabetes study of Efron, Hastie, Johnstone and Tibshirani (2004) records ten baseline measurements and a measure of disease progression one year later for 442 patients; it carries the regression examples. The Breast Cancer Wisconsin (Diagnostic) data (Street, Wolberg and Mangasarian, 1993) describe 569 fine-needle aspirates, 212 from malignant masses, and carry the classification examples. Seeded simulations with a known truth measure what real data cannot show, such as the bias of an estimate or the true error of a fitted model.

Articles, in order

  • The Bias-Variance Tradeoff: the expected squared error of a prediction split exactly into noise, squared bias and variance, derived step by step and measured by simulation; the optimism of the training error, $2p\sigma^2/n$ for least squares, which does not depend on the bias; how more data moves the best complexity; nearest neighbors on the diabetes data; and where the classical picture stops.
  • Binary Classification Metrics: the confusion matrix read in two directions, sensitivity and specificity against precision and predictive values; choosing a cutoff by Youden's index or by the costs of the two errors; the ROC curve and the proof that its area is the share of correctly ordered pairs; how prevalence changes precision but not the ROC curve; and calibration.
  • Loss Functions for Classification: the 0-1, absolute, squared and log losses on probabilities; proper scoring rules, and why absolute loss rewards exaggeration; five classifiers compared on training and test data; and the margin view of the logistic, hinge, exponential and squared losses that train classifiers, with what each one's minimizer estimates.
  • Loss Functions for Regression: MSE, RMSE and MAE, the bounds that tie RMSE to MAE, and the mean, median and quantiles as the best constants under squared, absolute and pinball loss; Huber's loss and what one bad value does to a fit and to a test score; MAPE and its pitfalls; and five models compared on held-out patients.
  • Training, Validation, and Test Sets: parameters and hyperparameters; the separate jobs of the three parts; how noisy one holdout estimate is and why; the winner's curse, proved to make the chosen model's score optimistic; leakage, with the wrong way to select inputs reproduced by simulation; and stratified splits.
  • Cross-Validation: K-fold and leave-one-out estimates; the leverage shortcut that gives leave-one-out for least squares from one fit, and its extension to whole folds; the bias and variance of the estimates measured for different numbers of folds; what cross-validation estimates and why its usual standard error is too small; and tuning with nested cross-validation.
  • The Bootstrap Method: resampling with replacement and the plug-in idea; standard errors and percentile intervals for a median and a regression slope; how many resamples are enough; where the bootstrap fails; and bootstrap estimates of prediction error, from the naive version through the leave-one-out bootstrap to the .632 and .632+ estimators.
  • Model Selection: best subset and stepwise searches; Mallows' $C_p$ derived from the optimism of the training error, AIC as its likelihood generalization and BIC from a Bayesian approximation, each read as a threshold on an input's $t$ statistic; cross-validation with the search inside the folds and the one-standard-error rule; a simulation that compares every rule against a known truth; and what selection does to the chosen model's reported uncertainty.

The order runs from the nature of prediction error to its measurement and then to decisions. The first article says what is being estimated, the next three give the scores, the fifth sets out how data must be divided for a score to be honest, the sixth and seventh replace one division by resampling, and the last uses them all to choose a model. Each article ends with worked problems that extend it on its own data and open questions for a reader or an agent running the repository's experiments; every number is recomputed, with assertions, by a script in tools/experiments/data-science/.

Where the site goes deeper

The theory beneath these applied articles is proved in the Statistics collection. Prediction Error and Model Choice proves the optimism of the training error for any fitting rule in Optimism and Effective Degrees of Freedom, derives AIC and BIC in Akaike's Information Criterion, Derived and The Bayesian Information Criterion and the Laplace Approximation, and proves what K-fold cross-validation estimates and why its naive standard error is too small in What Cross-Validation Estimates. Resampling Methods proves why the bootstrap works in The Plug-In Principle and Why the Bootstrap Works and derives the percentile, basic, studentized and BCa intervals in Bootstrap Confidence Intervals, with The Jackknife and Resampling Dependent and Clustered Data beside them. Statistics of Model Evaluation treats the uncertainty of a score and the comparison of two models, in Standard Errors for Benchmark Scores, Paired Comparisons of Models and Power Analysis for Evaluations, and proves which scoring rules are proper in Calibration and Proper Scoring Rules. Empirical Risk Minimization and Selective Inference and the Garden of Forking Paths prove that a rule chosen for its small error is optimistic about it. For text classification, the Academics section's Evaluating Classifiers covers precision, recall and F1 with micro- and macro-averaging.

Several subjects the unit touches would fit a later collection of their own: class imbalance, data leakage in its many forms, conformal prediction, evaluation under distribution shift, and the evaluation of forecasts, where rolling-origin validation replaces random splits.

References

  • Efron, B., Hastie, T., Johnstone, I., and Tibshirani, R. (2004). Least angle regression. The Annals of Statistics, 32(2), 407–499. record · 21 pages
  • Hastie, T., Tibshirani, R., and Friedman, J. (2009). The Elements of Statistical Learning: Data Mining, Inference, and Prediction (2nd ed.). Springer. record · 39 pages
  • James, G., Witten, D., Hastie, T., and Tibshirani, R. (2021). An Introduction to Statistical Learning with Applications in R (2nd ed.). Springer. record · 39 pages
  • Street, W. N., Wolberg, W. H., and Mangasarian, O. L. (1993). Nuclear feature extraction for breast tumor diagnosis. In Biomedical Image Processing and Biomedical Visualization, Proceedings of SPIE 1905 (pp. 861–870). record · 2 pages