Actuarial Notes

Train-Test Split

Study guide: Exam SRM

A Train-Test Split divides the available data into disjoint parts that do different jobs:

  1. The training data fit the model's parameters.
  2. A validation set compares candidate models and tunes their hyperparameters.
  3. A test set estimates, once, the test error of the model finally chosen.

Each part can judge a step only if that step has never seen it, so every reuse of a held-out set to make a decision turns it, gradually, into training data.

The test error of the model fitted to the training data is estimated by

\widehat{\text{Err}} = \frac{1}{n_{\text{test}}}\sum_{i \in \mathcal{D}_{\text{test}}} L\left(y_i, \hat{f}_{\text{train}}(x_i)\right)

  • \mathcal{D}_{\text{test}} is the test set and n_{\text{test}} the number of observations in it.
  • \hat{f}_{\text{train}} is fitted to the training data only.
  • L is the loss: squared error for a numeric response, deviance for a GLM, or the misclassification rate for a classifier.

The validation set approach

ISLR's validation set approach (James et al., §5.1.1) splits the data in two, fits on one part and scores on the other. The split is random, so different splits give different estimates, and a model fitted to only part of the data tends to overstate the test error. Tuning and model choice can instead use k-fold cross-validation inside the training data, which leaves the test set free for the last step. After selection, the model is usually refitted on the training and validation data together before it is used.

Optimism from reusing a held-out set

A holdout sample that has been used to choose between models has become a validation set, and its error for the winner is no longer an unbiased estimate. When several candidates are scored on one shared held-out set,

E\left[\min_k \widehat{\text{Err}}_k\right] \leq \min_k \text{Err}_k

  • \text{Err}_k is the true test error of candidate model k.
  • \widehat{\text{Err}}_k is its estimate on the shared held-out set.

Each estimate is unbiased for its own model, but the smallest of many noisy estimates is biased downward. The bias grows with the number of comparisons and with the noise in each estimate. Re-tuning after each look at the test set, adding a feature because the test error improved, or dropping one because it worsened all fit the model to that particular sample, so the final test error is optimistic.

What validation MSE should this analyst expect to report for the chosen model? An analyst compares ten candidate frequency models on one validation set. Unknown to the analyst, all ten have the same true test MSE of 400. Each validation MSE equals the true value plus an independent error with standard deviation 12. The expected maximum of ten independent standard normal variables is 1.539.

Answer

  • The analyst keeps the model with the smallest validation MSE, and the smallest of ten draws sits about 1.539 standard deviations below their common mean.
  • The expected reported MSE is 400 - 1.539(12) = 400 - 18.5 = 381.5.
  • The reported error understates the truth by 18.5, or 4.6\%, although no model is better than any other.
  • A fresh test set, used once, would show about 400 for the chosen model.

Making the split

The split is random but done at the right unit, so that one policy's renewals or one claim's transactions do not fall on both sides. A rare outcome calls for sampling within each class (stratifying), so every set holds enough events. When conditions drift over time, an out-of-time test set (the latest year) also checks stability. Every step that learns from the data, such as scaling, imputing or screening variables, must be fitted on the training data alone and applied unchanged to the other sets.

Tuning on the test set Choosing a hyperparameter or a model by test error and then reporting that error as unbiased overstates the model's accuracy. Once the test set has chosen anything, a different set must report the result.

Practice questions

Actuarial Notes