A model that forecasts the probability of a down day fits its training sample almost perfectly. Does that say how well it will forecast next year, and can its outputs be read as probabilities? A small training error, a useful prediction and a calibrated probability are three different mathematical statements. This lesson defines empirical risk and regularization, derives the ridge estimator exactly, proves that the Brier loss rewards honest probabilities, defines calibration, and states when a change in the sampling law can be handled by reweighting the training data.
Key terms
Empirical risk
Definition Let be a prediction rule with parameter and a loss. The population risk under the law of the pairs that the rule is meant to predict is
when the expectation exists. For a training sample the empirical risk is the average loss
Regularized empirical risk minimization chooses a minimizer of , with a penalty and a strength . If each training pair has the law , then for every fixed . A parameter chosen from the sample is not fixed, though. Under the same hypothesis and with , a minimizer of the empirical risk and a minimizer of the population risk satisfy
provided these expectations exist, because and hold on every sample. Here is the expected loss of the fitted rule on a new pair drawn from independently of the sample.
In plain words The empirical risk is the score on data already seen, and the population risk is the score on the data the rule will meet. Because an unpenalized fit picks its parameter to make the first score small, its training score is optimistic on average about the second. A penalty adds a preference, such as small coefficients, and trades some fit for less sensitivity to the particular sample. The best strength of that preference need not be the same for every population.
Example Fit with squared loss to the two constructed pairs and . The empirical risk is
which is at and at . Now suppose a constructed population in which is or with probability each and , where is independent of with mean and variance . Since , the population risk is , so while . With instead, and . The same two training scores are consistent with either ranking of the two rules in the population.
Ridge estimator
Definition Let be an design matrix, here a matrix of observed feature values, and the target vector, with no intercept and a strength . The ridge estimator minimizes
Its gradient is . Setting it to zero and multiplying by gives the normal equations
For every nonzero ,
so the matrix is positive definite and invertible even when the columns of are linearly dependent. The Hessian is positive definite as well, so is strictly convex and its unique minimizer is
With the problem is ordinary least squares, whose inverse formula needs full column rank. Without full rank its minimizers form an affine set, and the pseudoinverse solution is the one with the smallest Euclidean norm. An unpenalized intercept in the first column changes the penalty to with and the matrix to , which is still positive definite when that column is the vector of ones. The factor appears because the fitting error is averaged and the penalty is not. An objective written without the factor has in its place.
In plain words Ridge regression charges for large coefficients. That pulls the fit toward zero and gives a unique, stable solution even when some directions in the data are poorly identified. The penalty depends on the units of the features, so the features are usually put on a common scale first, with the scaling statistics taken from the fitting data only.
Example For the pairs and with and , the products are and , so . The fitted values are and , the residuals are and , the mean squared error is , the penalty is and the objective is . The coefficient fits both points exactly but scores on this objective. Here , so gives and gives . Choosing by looking at an evaluation set makes that set part of model selection, so its score is no longer an untouched assessment, a point taken up in Time series validation and overlapping labels.
Brier loss
Definition For a binary outcome and a reported probability , the Brier loss is , and the Brier score of forecasts is the average . Let be the true conditional probability given the features, and let the report be a function of . Weighting the two possible errors by their conditional probabilities and adding and subtracting gives
The first term is the conditional variance of the event indicator and does not depend on the report. The second is zero only at . The loss is dimensionless and lies in .
In plain words The Brier loss is the squared error of a probability used as a forecast of an outcome that is zero or one. Its expected value splits into the uncertainty of the event itself, which no report can remove, and a penalty for reporting a probability other than the true one.
Example Let the event probability be in a constructed population. Reporting gives the expected loss , and reporting gives . The difference is exactly , while the part remains whatever is reported.
Proper loss
Definition A loss for probability reports of a binary event is proper if, for every , the expected loss
is minimized over at , and strictly proper if is its only minimizer. The Brier loss is strictly proper, because , including the degenerate cases and . The log loss , with the natural logarithm, is strictly proper too. For and in ,
which is negative for and positive for , so is the unique minimizer, while the reports and give infinite expected loss. For the minimum is at the matching endpoint, with the convention . The absolute loss is not proper, since is linear in and is minimized only at whenever .
In plain words Under a proper loss, a forecaster whose information gives the event probability cannot lower the expected loss by reporting anything else, so honest reporting is optimal on average. An improper loss such as absolute error rewards pushing reports toward zero or one, so its best reports are not probabilities at all.
Example With , the expected log loss of the honest report is , and that of is about , a gap of about . Under absolute loss the honest report has expected loss , while the report has . A forecaster scored by absolute error does better by claiming certainty.
Probability calibration
Definition Let and let be a reported probability with values in . The forecast is calibrated under if
almost surely. When takes finitely many values, this means for every value with . The true conditional probability is calibrated by the tower property, and so is the constant forecast equal to the base rate . Write . The squared-error identity of Financial prediction and feature construction, applied with the information generated by , and the law of total variance give
The last term, the reliability term, is zero exactly when the forecast is calibrated. The middle term, the resolution, measures how far the forecast separates cases with different event rates, which calibration alone does not provide.
In plain words Among all the cases that receive the forecast , the event should occur with frequency in the population the forecast is used on. A forecast can pass that test while being useless for telling high-risk cases from low-risk ones, and a forecast can rank cases perfectly while its numbers are too extreme. Calibration and discrimination are therefore checked separately, and a calibration map fitted from data is judged on predictions it was not fitted to, such as held-out or cross-fitted ones.
Example In the two-regime model of the previous lesson, let for the up move, so and . The constant forecast is calibrated, with Brier risk and no resolution. The forecast in the high regime and in the low regime is calibrated, its resolution is and its Brier risk is . The forecast in the high regime and in the low regime ranks the regimes the same way, but is still and , so its reliability term is and its Brier risk is , worse than the constant forecast.
Distribution shift and covariate shift
Definition Let be the law of the training pairs and the law of the pairs on which the rule will be used, both physical laws of observations. A distribution shift is any difference between the two laws. Covariate shift is the case in which the law of changes while the conditional law of given stays the same, at least for deployment-almost every . Suppose in addition that the deployment law of gives probability zero to every set of training probability zero, which is absolute continuity, so that it has a density ratio with respect to the training law of . Where both laws have densities, at points with . If also , then
The proof writes the deployment risk as an integral of the loss against the common conditional law of and the deployment law of , and then multiplies and divides by where it is positive. If the conditional law changes as well, the weights alone no longer give the deployment risk. If deployment reaches a region the training law never visits, no weight exists, and the training sample carries no information about the loss there.
In plain words Under covariate shift the relation between features and outcome is unchanged and only the mix of situations differs, so training observations from situations that become more common get larger weights and the rest get smaller ones. The identity is exact for the population, but a finite weighted average can be unstable when a few weights are very large, and the weights usually have to be estimated. The conditional mean function is unchanged, yet the best rule within a restricted class, such as linear rules, can change with the law of . Both laws here are physical laws of observations, and nothing in this card is a change to a pricing measure.
Example Return to the two-regime model with the forecast in the high regime and in the low regime, whose conditional squared-error losses are and . In training the high regime has probability and the risk is . In a constructed deployment period the high regime has probability and the up probabilities stay and . The weights are and , and
which equals the deployment risk . If instead the up probability in the high regime also falls to , the conditional mean there becomes , and the forecast has loss in that regime. The deployment risk is then , while the reweighted training risk still reports .
Check yourself
- Fit without an intercept to the pairs and , using the ridge objective of this lesson with . Find the ridge coefficient and the least-squares coefficient, and compare their objective values.
Show the answer
Here , , and , so the ridge coefficient is and the least-squares coefficient is . At the residuals are and , the mean squared error is , the penalty is and the objective is . At the residuals are and , the mean squared error is , the penalty is and the objective is . The ridge fit has the larger training error and the smaller objective, as the unique minimizer must. Neither number says which coefficient predicts better on new data.
- Given everything a forecaster knows, an event has probability . The forecaster considers reporting instead of to sound decisive. Compare the expected Brier loss and the expected absolute loss of the two reports. Which of the two losses is proper?
Show the answer
Under the Brier loss the honest report has expected loss , which is , and the report has . The difference is , so honesty wins. Under absolute loss the honest report has , while the report has , so the extreme report wins. The Brier loss is strictly proper. The absolute loss is not proper, because its expected value is smallest at .
- A model is fitted on a sample in which high-volatility days are percent of all days, and it will be used in a period in which they are percent. Its mean squared errors, conditional on the type of day, are on high-volatility days and on the others, and the relation between features and returns is assumed unchanged. Find the training risk, the weights and the deployment risk obtained by reweighting. What goes wrong if the deployment period also contains a crisis state that never occurs in training?
Show the answer
The training risk is . The weights are for high-volatility days and for the others, and the reweighted training risk is
which equals . The same model has almost twice its training risk in deployment, only because the mix of days changes. A crisis state that has training probability zero but positive deployment probability breaks absolute continuity. No weight can represent it, the training sample contains no losses from that state, and the identity gives no estimate of the deployment risk. The identity also fails if the relation between features and returns changes, even on days of familiar types.