§ 1.7Module I

Overfitting and Underfitting

1.7 — Overfitting and Underfitting

Recall first. A model gets 100% on training data and 60% on validation data. Is it good, bad, or impossible to tell? Name the missing evidence.

The central goal: fit the future

A model should learn structure that transfers to new examples. It should not merely memorize the training set, and it should not be so restricted that it misses the main pattern.

A score such as 100% training accuracy is not a diagnosis by itself. We need a validation or test comparison and a meaningful split.

Model complexity and the U-shaped validation curve

A typical pattern is:

error
  ^       validation/test error
  |          \      /
  |           \____/
  | training error \________
  +----------------------------> model complexity
       underfit   useful   overfit

As complexity increases, training error often decreases because the model has more freedom to fit the sample. Validation error may first decrease, reach a useful region, and then rise as the model begins to fit sample-specific noise. The exact curve is not guaranteed; it is a diagnostic pattern, not a law.

Recognizing the symptoms

Training errorValidation/test errorLikely interpretationFirst questions
HighHigh and similarUnderfitting, weak features, or noisy taskIs the model too simple? Is the target predictable?
LowLow and similarCandidate good fitIs the split honest and the data representative?
Very lowMuch higherOverfitting, leakage problem, or distribution shiftIs the model too flexible? Was validation isolated?
LowUnstable across splitsHigh variance or too little dataDoes performance change with samples or groups?

A large train–validation gap is evidence to investigate, not proof of one cause. Leakage can produce a misleadingly good validation result rather than the ordinary overfitting pattern.

Causes of underfitting

Possible responses include improving features, choosing a more expressive model, reducing excessive regularization, or training appropriately. More complexity is not automatically the answer.

Causes of overfitting

Possible responses include collecting representative data, simplifying the model, regularization, early stopping, feature selection, data augmentation where valid, and cross-validation. The remedy must match the cause.

Learning curves

A learning curve plots performance against training-set size or training progress. It can reveal different situations:

Do not confuse a learning curve with a single final score. The shape explains how performance changes.

Worked example — polynomial degree

Suppose we predict a curved physical measurement from one input using polynomial regression:

DegreeTraining MSEValidation MSE
118.019.5
34.05.2
120.231.0

Degree 1 is likely underfitting: both errors are high. Degree 3 is the best candidate here: it reduces both errors. Degree 12 is likely overfitting: it nearly memorizes training observations but performs poorly on validation data.

The conclusion is not “always choose degree 3.” The useful complexity depends on the data, loss, split, and deployment distribution.

Exercise

Diagnose each pattern and suggest one response:

  1. A shallow decision tree has high training and test error.
  2. A very deep tree has zero training error and poor validation error.
  3. A model has excellent validation accuracy, but the validation records contain future information.
Answers
  1. Likely underfitting; consider better features or a more expressive tree, after checking the target and labels. 2. Likely overfitting; restrict depth, regularize, collect data, or use validation-based selection. 3. The score is contaminated by leakage; rebuild the split and preprocessing before diagnosing model quality.

Exam lens

Three-pattern answer:

Long-answer skeleton: define the two failures, draw error against complexity, give causes, then give matched remedies. State that validation/test performance—not training performance alone—decides generalization.

Common traps:

Rapid revision

Sources

Footnotes

  1. Google, “Overfitting.” https://developers.google.com/machine-learning/crash-course/overfitting/overfitting — definitions, loss curves, causes, and generalization conditions. 2

  2. scikit-learn, “Getting Started.” https://scikit-learn.org/stable/getting_started.html — model evaluation and cross-validation workflow.