What Does a Prediction-Error Number Describe?
A regression model can have a small average error on one set of observations and still perform poorly on the cases where it will actually be used. The key question is not only how large is the error? It is also for which population, under which sampling design, and for a model trained on how much data? A test-set or cross-validation result is useful only when its answer matches the prediction task of interest.
For example, a model evaluated on a random sample of patients from several clinics may be intended for new patients at those same clinics. That evaluation does not automatically tell us how well it will predict at a new clinic, or in a future population with different characteristics. The split is part of the definition of what is being assessed.
Define the Target Before the Estimate
Suppose \(X\) denotes a new case’s predictor values and \(Y\) its outcome. A fitted regression model, based on training data \(D\), gives a prediction \(\hat f_D(X)\). To describe predictive performance, we must specify a loss function: a numerical measure of the discrepancy between the observed outcome and its prediction. For squared-error loss, the loss is \((Y-\hat f_D(X))^2\); for absolute-error loss, it is \(|Y-\hat f_D(X)|\).
With squared-error loss, risk is the target-population mean squared prediction error. Its square root is the root mean squared error, which is on the same scale and in the same units as \(Y\). With absolute-error loss, risk is the target-population mean absolute error, also in the units of \(Y\). The chosen loss matters: two models can rank differently under squared and absolute error because squared error gives more weight to large misses.
There is a second quantity to keep distinct from the risk of one fitted model. A learning procedure is the rule used to fit a model from training data. If \(D\) itself is regarded as a random sample of a stated size, the procedure’s expected predictive risk averages over both the possible training samples and new target-population cases. This quantity describes the procedure at that training-sample size; it is not the conditional risk of a particular fitted model.
When a Holdout Average Estimates Target Risk
Suppose a model has been fitted using training data \(D\), and a separate test set contains \(m\) cases. If the test cases are independent draws from the target population and the model is held fixed, the average test loss estimates the risk of that fitted model. This statement depends on the test cases representing the target population and being separate from the data used to fit the model.
For this average to be an unbiased estimate of \(R_P(\hat f_D)\), assume that, conditional on \(D\), the test cases are independent and identically distributed from \(P\), the fitted model is not changed using their outcomes, and the expected loss is finite. Under those conditions, each test loss has conditional expectation \(R_P(\hat f_D)\). Linearity of expectation then gives:
This is a justification of the estimate’s target, not a claim that any one test-set average equals the risk exactly. A finite test set varies from sample to sample, so its average loss has sampling variability. This tutorial focuses on what the estimate represents; the size and uncertainty of an evaluation are separate questions.
Worked Example: Interpreting a Random Test-Set Error
Suppose a fitted model predicts a hypothetical outcome measured in hours. Four independent test cases, drawn from the intended target population, have observed outcomes 10, 12, 8, and 15 hours. The model predicts 11, 10, 9, and 12 hours. Calculate the test mean squared error and root mean squared error, and state what they estimate.
The prediction errors, observed minus predicted, are \(-1, 2, -1,\) and \(3\) hours. The squared errors are \(1, 4, 1,\) and \(9\) hours squared. Thus:
The root mean squared error is:
Under the stated sampling conditions, the test mean squared error estimates this particular fitted model’s mean squared prediction error for new cases from the target population. The root mean squared error summarizes error on the hours scale. Neither number guarantees that future prediction errors will have that size, and neither describes populations that were not represented by the test sampling design.
Sampling and Splitting Define the Population Represented
A test set need not represent the intended target population merely because it was kept out of model fitting. A random split of an appropriate sample can support a target-population interpretation when the original cases are sampled in a way that represents the target. But a split cannot repair a mismatch between the available data and the intended future cases. If some groups are overrepresented, some settings are absent, or observations are selected from a different time period, the average test loss may describe that particular mix instead.
The distinction is especially clear when test cases are deliberately sampled in different proportions from their proportions in the target population. An unweighted average then gives more influence to groups that were sampled more heavily. If group-specific losses are available and the target group proportions are known, a weighted average can instead match the target composition. That adjustment is justified only if the within-group test cases represent their corresponding target groups.
Worked Example: An Oversampled Group Changes the Estimate
Imagine the target population consists of 80% group A and 20% group B. A test set is deliberately balanced, with half its cases from each group. Suppose the mean squared prediction error is 4 outcome-units squared for group A and 25 outcome-units squared for group B. Find the unweighted test-set mean squared error and the target-weighted mean squared error.
Because the test set is half from each group, its unweighted average is:
That value describes the balanced test-set mix. To represent the stated target population, weight the group errors by the target proportions:
The corresponding target-weighted root mean squared error is \(\sqrt{8.2}=2.864\) outcome-units. The unweighted root mean squared error is \(\sqrt{14.5}=3.808\) outcome-units. These differ because the balanced test set gives group B more influence than its 20% share in the target population. The weighted calculation estimates target-population error only if the group-specific errors are themselves representative of their target groups.
The split design also defines which kinds of new cases are being represented. A random division of cases drawn from the same settings is aimed at new cases from that mixture of settings. If the intended task is prediction in future periods, a test set from a different period may better represent that task. If the task is prediction at a new site, holding out cases from sites that also appear in training does not directly estimate performance at unseen sites. These are different target populations or sampling conditions, so their risks need not be equal.
What Cross-Validation Represents
Cross-validation evaluates predictions for cases left out of the data used to fit the model that predicts them. Its result is therefore associated with the way cases are assigned to training and held-out portions, and with the size and composition of those portions. In ordinary \(K\)-fold cross-validation, each fitted model uses approximately \((K-1)/K\) of the available cases. The pooled average of held-out losses describes performance for models trained on subsets of roughly that size, under the relevant data-splitting design.
This makes cross-validation a way to assess a learning procedure at a particular training-set size, rather than a direct test of the exact model later fitted to all available data. The final model may use more cases and therefore differ from the cross-validation fits. How much its risk differs is not determined by the cross-validation average alone.
Worked Example: Identifying the Training Size Behind a Cross-Validation Result
A hypothetical data set has 100 cases. In five-fold cross-validation, each fitted model is trained using 80 cases and makes predictions for the 20 cases in its held-out fold. Suppose the mean squared errors in the five folds are 12, 18, 15, 20, and 10 outcome-units squared, with 20 cases in each fold. Find the pooled cross-validation mean squared error and state its target.
Since the fold sizes are equal, pooling all 100 held-out losses is equivalent to averaging the five fold mean squared errors:
The result summarizes held-out performance for the fitting procedure when trained on 80 cases, under the particular fold assignment and sampling design. It is not, by definition, the exact risk of a final model trained on all 100 cases, nor does it automatically represent a different population such as cases from new sites. The root mean squared error corresponding to this average squared error is \(\sqrt{15}=3.873\) outcome-units.
A Practical Check on the Intended Interpretation
Before interpreting a holdout or cross-validation result, specify four things: the target cases, the loss function, the sampling or splitting design, and the training-set size associated with the evaluated models. This prevents a numerical estimate from being treated as more general than its design supports.
Describe the population and settings where predictions will be used, including any relevant time or group distinction.
State whether performance is summarized with squared error, absolute error, or another measure, and give its units when applicable.
Ask whether the test cases or folds reflect the target population, or whether unequal sampling requires a justified adjustment.
State whether the number describes one fixed model or a fitting procedure evaluated at a particular training-set size.
Common Mistake: Treating “Held Out” as “Representative”
A common but incorrect argument is: “These cases were not used to fit the model, so their average error estimates performance on any future cases.” Being held out addresses whether those outcomes were used to fit the evaluated model; it does not establish that the cases represent every population where the model might be used. A test set sampled only from one clinic, for instance, cannot by itself establish performance at clinics with different patients or practices.
The correction is to name the population supported by the sampling design and limit the interpretation to it. Likewise, a cross-validation result should be tied to the fitting procedure and training size represented by its folds. A valid estimate answers a specific predictive question; a different target population calls for an evaluation design that represents that population.
Check Your Understanding
Answer each question by identifying the target population or training procedure represented.
- A test set is an independent random sample from the intended target population. Under what conditions does its average loss estimate the risk of a fitted model?
- A target population is 90% group A and 10% group B, but the test set contains equal numbers from each group. Why might the unweighted test error not estimate target-population error?
- In cross-validation, each fitted model uses only a subset of all available data. What does the resulting average most directly describe?
- A model is tested on new patients from the clinics represented in training, but it will be used at entirely new clinics. What limitation does this create for interpreting the estimate?
- Why are the risk of one fitted model and the expected risk of a learning procedure different quantities?