Tutorials › Exam SRM - Statistics for Risk Modeling › Recognizing Overfitting

Exam SRM · Bias, Variance, and Overfitting · Tutorial 764 of 926

Recognizing Overfitting

Use training and validation performance together to identify evidence of overfitting and explain why a model that fits sample-specific noise may predict poorly.

Intermediate 10 min read

What You'll Learn

  • Define overfitting through the relationship between training and validation performance
  • Calculate and interpret a training-validation gap using a common loss scale
  • Explain how fitting sample-specific noise can reduce training error without improving prediction
  • Distinguish evidence of overfitting from proof that overfitting is the only problem
  • Avoid common traps involving raw error counts, mismatched metrics, and noisy validation estimates

Recognizing Overfitting

A model can describe its observed data very closely and still make poor predictions on new observations. The key diagnostic is not training performance alone, but how that performance compares with validation performance measured on data not used to fit the model. A strong training result paired with a materially worse validation result is evidence that the model may have adapted to features of the training sample that do not persist in the population.

This pattern is called overfitting. It can occur when a model is sufficiently flexible to capture not only real structure in the data, but also random variation specific to the observations used for fitting. The model then appears especially accurate on those observations, while its advantage diminishes or reverses on other observations from the same prediction setting.

Definition: A model is overfitting when its fitted structure captures sample-specific variation in the training data in a way that harms its ability to predict new observations. A common empirical warning sign is low training error paired with substantially higher validation error, calculated using the same prediction target and loss function.

Training error measures performance on the data used to estimate the model. Validation error measures performance on a separate sample that was not used for that fitting. For a quantitative response, one common measure is mean squared error (MSE), the average of the squared differences between observed responses and predictions. For a categorical response, one possible measure is the misclassification rate, the fraction of cases whose predicted class is incorrect. A fair comparison requires using the same metric on both sets.

A training-validation difference is a diagnostic, not a verdict. A larger validation error may be consistent with overfitting, but it can also reflect a small or unusually difficult validation sample, a difference between the training and validation populations, or a mismatch between the chosen loss and the prediction goal. Context matters when interpreting the size and meaning of the difference.

Comparing Performance on a Common Scale

For a loss where smaller values are better, define the observed training-validation gap as validation loss minus training loss. A positive gap means the model performs worse on the validation sample. Its size must be interpreted in context: a small difference may be ordinary sampling variation, while a large, repeatable difference may be more concerning. The gap is meaningful only when the two losses are calculated comparably.

$$ \text{Training-validation gap} = \text{validation loss} - \text{training loss} $$

For MSE, use the same response scale and the same squared-error calculation on each set. For a misclassification rate, divide the number of classification errors by the number of observations in that set. Do not compare raw error counts when the training and validation sample sizes differ: counts depend on both performance and the number of cases.

Worked Example: Comparing Regression Models by MSE

A hypothetical pricing team compares two models for predicting claim-handling time in hours. Assume observations follow \(Y=f(X)+\varepsilon\), where \(f\) is the population mean response and \(\varepsilon\sim N(0,4)\) independently across observations. Thus the error has mean zero and variance 4 hours squared. On four training observations, Model A has residuals \(1,-1,2,-2\); Model B has residuals \(0,0,1,-1\). On four separate validation observations from the same population, Model A has residuals \(1,-1,1,-1\); Model B has residuals \(3,-3,2,-2\). Calculate each MSE and identify the stronger overfitting warning. Residuals are observed response minus prediction.

Method. For each model and data set, square the residuals, sum them, and divide by the number of observations. This puts training and validation performance on the same scale.

For Model A on training data, the squared residuals are \(1,1,4,4\). Their sum is \(10\), so its training MSE is \(10/4=2.5\). On validation data the squared residuals are \(1,1,1,1\), which sum to \(4\). Its validation MSE is \(4/4=1\). The gap is \(1-2.5=-1.5\); this validation sample does not show Model A performing worse.

For Model B on training data, the squared residuals are \(0,0,1,1\), which sum to \(2\). Its training MSE is \(2/4=0.5\). On validation data the squared residuals are \(9,9,4,4\), which sum to \(26\). Its validation MSE is \(26/4=6.5\). The gap is \(6.5-0.5=6.0\).

Model B has the lower training MSE, but its validation MSE is much higher than its training MSE. This is a clear warning pattern for overfitting relative to Model A on these samples. It does not establish that overfitting is the only possible explanation: with only four validation observations, the measured validation MSE could also be affected by sample variability. The calculation avoids the mistake of selecting a model solely because its training MSE is smallest.

Check: Model B's training squared errors sum to \(2\), and its validation squared errors sum to \(26\). Dividing each by four gives \(0.5\) and \(6.5\), respectively, as reported.

Why Fitting Noise Creates a Gap

The mechanism can be shown with a simple nested linear-model argument. Suppose the responses satisfy \(Y=f(X)+\varepsilon\), with independent errors of mean zero and variance \(\sigma^2\), and consider adding \(q\) fitted directions that have no real signal. In this idealized setting, those added directions can still align with random errors in the training sample. Least squares uses that alignment to reduce training residual sum of squares.

Let \(\boldsymbol{\varepsilon}\) be the vector of training errors, and let \(P\) be the projection matrix onto the \(q\)-dimensional space of added directions, after accounting for the original model. The fitted noise component is \(P\boldsymbol{\varepsilon}\). The reduction in training residual sum of squares from fitting this component is \(\boldsymbol{\varepsilon}^{\mathsf T}P\boldsymbol{\varepsilon}\). Since the errors have covariance matrix \(\sigma^2 I\), the expected reduction is \(\sigma^2\operatorname{tr}(P)\). A projection onto \(q\) independent directions has trace \(q\), giving the result below.

$$ E\!\left[\boldsymbol{\varepsilon}^{\mathsf T}P\boldsymbol{\varepsilon}\right] = \sigma^2\operatorname{tr}(P) = q\sigma^2 $$

This is a training-sample result: even directions that represent no population signal can lower expected training error. For a new observation with independent error, the fitted training noise does not recur in the same way. Consequently, the apparent training improvement need not carry over to validation data. If the extra directions do capture genuine signal, they may improve predictions instead; the argument identifies a noise-fitting mechanism, not a rule that every complex model is harmful.

1
Find what the model learned.
Estimate model parameters using the training observations. A flexible model can adapt to both systematic structure and accidental features of this particular sample.
2
Measure training performance.
Because the fitted model was chosen using these observations, features it has adapted to can make its training loss unusually small.
3
Evaluate on validation observations.
Sample-specific noise from the training data is generally not repeated in the validation observations, so a noise-driven improvement may disappear.

Worked Diagnostics Across Model Complexity

Worked Example: Locating the Overfitting Warning

A hypothetical insurer models claim-reporting delay in days. Assume \(Y=f(X)+\varepsilon\), with \(\varepsilon\sim N(0,4)\) independently, and that training and validation observations come from the same population. Three nested candidate models are evaluated. The training set has 30 observations and the validation set has 20. Their squared-error sums are: Model 1, 120 training and 100 validation; Model 2, 60 training and 80 validation; Model 3, 12 training and 180 validation. Compute the MSEs and gaps, then identify the strongest warning.

Method. Divide each squared-error sum by its own sample size before comparing performance.

For Model 1, training MSE is \(120/30=4\), and validation MSE is \(100/20=5\). Its gap is \(5-4=1\).

For Model 2, training MSE is \(60/30=2\), and validation MSE is \(80/20=4\). Its gap is \(4-2=2\).

For Model 3, training MSE is \(12/30=0.4\), and validation MSE is \(180/20=9\). Its gap is \(9-0.4=8.6\).

Training MSE decreases from \(4\) to \(2\) to \(0.4\), while validation MSE first decreases from \(5\) to \(4\) and then increases to \(9\). Model 3 has the strongest overfitting warning: it fits the training observations best but performs worst on validation data. Model 2 has the smallest validation MSE among these candidates. This conclusion describes the supplied validation results; it does not guarantee which model has the lowest population prediction error.

Common mistake avoided. The raw validation sum for Model 1, \(100\), is smaller than Model 3's sum, \(180\), but the sets have different sizes. Comparing the sums would be misleading. The corresponding MSEs, \(5\) and \(9\), correctly account for the denominators.

Check: Each MSE uses the stated denominator: 30 for training and 20 for validation. For example, Model 3's validation MSE is \(180/20=9\), not \(180/30=6\).

Classification Errors and Unequal Sample Sizes

Worked Example: Comparing Misclassification Rates

A hypothetical model flags whether a commercial building requires a safety inspection. Suppose the population is balanced between the two classes, and labels are independently flipped from an underlying deterministic classification rule with probability \(0.08\). A simpler model makes 8 errors among 80 training buildings and 6 among 30 validation buildings. A more flexible model makes 3 errors among the 80 training buildings and 9 among the 30 validation buildings. Calculate the error rates and explain the warning. The error counts are observed outcomes from this hypothetical setting.

Method. Divide errors by the number of observations in each set; comparing counts alone is not valid because the denominators differ.

For the simpler model, the training misclassification rate is \(8/80=0.10\), or \(10\%\). Its validation rate is \(6/30=0.20\), or \(20\%\). The validation-minus-training gap is \(20\%-10\%=10\) percentage points.

For the more flexible model, the training rate is \(3/80=0.0375\), or \(3.75\%\). Its validation rate is \(9/30=0.30\), or \(30\%\). Its gap is \(30\%-3.75\%=26.25\) percentage points.

The flexible model has fewer training errors, but it has a substantially higher validation error rate and a much larger positive gap. This is evidence consistent with overfitting. The smaller validation sample also makes its observed rate less stable than a rate from a larger sample, so the result should not be interpreted as proof about every future group of buildings.

Common mistake and correction. One might reason that the flexible model has only 9 validation errors compared with 8 training errors, so its validation performance is nearly as good. That comparison is wrong because the sample sizes are 30 and 80. The rates are \(9/30=30\%\) and \(3/80=3.75\%\), showing a much larger difference. As a second check, the simpler model has 6 validation errors, fewer than the flexible model's 9, but its validation rate is \(20\%\), not \(6\%\).

Check: The four rates are \(10\%\), \(20\%\), \(3.75\%\), and \(30\%\). The more flexible model's validation rate exceeds its training rate by \(26.25\) percentage points.

What the Pattern Does and Does Not Establish

The strongest evidence comes from a coherent comparison: the model has good training performance, validation performance is materially worse under the same loss, and the difference is not readily explained by how the samples or metric were constructed. A very small training error by itself is not enough. A weak model can have poor training and validation performance, while an overfit model can have excellent training performance but poor validation performance.

Before attributing a gap to overfitting, check the following:

  • Use comparable calculations. Confirm that training and validation errors use the same response definition, units, and loss function.
  • Respect denominators. Compare averages or rates, not raw sums or counts, when sample sizes differ.
  • Check the data setting. If training and validation observations come from different populations or conditions, a gap may reflect that difference rather than only sample-specific fitting.
  • Consider validation uncertainty. A finite validation sample can give an unusually high or low estimate of performance.
  • Describe the evidence precisely. Say that a large positive gap is consistent with overfitting, rather than claiming the gap proves its cause.

Overfitting matters because model quality is ultimately about performance beyond the observations used to fit it. In actuarial prediction, a model that memorizes accidental patterns in historical claim or policy data can appear highly accurate during fitting yet produce unreliable predictions for new cases. The validation comparison is therefore a practical warning: apparent training success may not represent generalizable structure.

Key takeaway: Diagnose overfitting by comparing training and validation performance on the same scale. A low training loss paired with a much higher validation loss is a warning that the fitted model may have captured sample-specific noise, but sample variability and differences in data conditions must also be considered.

Check Your Understanding

For each problem, compare performance using the stated metric and identify what the evidence supports.

  1. A hypothetical severity model assumes independent errors \(\varepsilon\sim N(0,9)\). It has training MSE \(3.2\) and validation MSE \(4.1\). Calculate the gap and state whether this alone establishes overfitting. (Answer: The gap is \(4.1-3.2=0.9\); it is a positive warning, but by itself it does not establish overfitting.)
  2. A classifier has 10 errors among 100 training records and 8 among 40 validation records. Calculate both misclassification rates and their difference in percentage points. (Answer: Training rate \(10\%\), validation rate \(20\%\), gap \(10\) percentage points.)
  3. Two models are evaluated on the same population with independent errors \(\varepsilon\sim N(0,4)\). Model A has training and validation MSEs of 2 and 3. Model B has training and validation MSEs of 0.5 and 5. Which has the stronger overfitting warning, and which has lower validation MSE? (Answer: Model B has the stronger warning, with gap \(5-0.5=4.5\) versus Model A's \(3-2=1\); Model A has lower validation MSE, \(3\) versus \(5\).)
  4. A regression model's training squared-error sum is 72 on 24 observations; its validation sum is 90 on 15 observations. Compute both MSEs and the gap. (Answer: Training MSE \(72/24=3\), validation MSE \(90/15=6\), gap \(6-3=3\).)
  5. A new flexible model lowers training misclassification from \(12\%\) to \(4\%\), while validation misclassification rises from \(14\%\) to \(23\%\). State the change in validation error and the change in the training-validation gap. (Answer: Validation error rises by 9 percentage points; the gap rises from \(14\%-12\%=2\) points to \(23\%-4\%=19\) points, an increase of 17 percentage points.)
Clinical Biostats