Bias, Variance and Generalization

Diagnosing underfitting and overfitting with learning and validation curves, and choosing the right fix for each.

Intermediate · about 4 hours · difficulty 3/5

Learn first: Cross-Validation

Every model error comes from some mix of bias (too simple to capture the pattern), variance (too sensitive to the particular training sample) and irreducible noise. Knowing which dominates tells you what to do next.

Diagnosis

  • High bias (underfitting): training and validation scores are both poor and close together.
  • High variance (overfitting): training score is great, validation score much worse.
  • Learning curves (score versus training set size) show whether more data would help.
  • Validation curves (score versus one hyperparameter) show the sweet spot of complexity.

Fixes

  • For bias: more expressive model, better features, less regularization, train longer.
  • For variance: more data, regularization, simpler model, ensembling, data augmentation, early stopping.

Modern nuance

Very large neural networks can fit training data perfectly and still generalize (double descent). The classical U-shaped curve is a guide, not a law, but the diagnostic habits still apply everywhere.

Good enough to move on when you can look at a pair of train and validation curves and prescribe the right next experiment.

Key concepts

  • Bias-variance decomposition
  • Learning curves
  • Validation curves
  • Regularization as variance control
  • Double descent

Mini project

Plot learning curves for a depth-2 tree, a fully grown tree and a random forest on the Adult income dataset and write the diagnosis and recommended fix for each.

Check yourself

Your learning curve shows training and validation scores converging at a low value. Will more data help? What would?

Free resources