advanced29 min studyLesson 751 in Mathematics

Risk, empirical risk, and excess risk

Separate population performance, sample fit, class approximation and optimization error.

On this page

What you’ll understand

  • Define risk and empirical risk with their distinct sources of randomness.
  • Separate excess risk relative to a class from excess risk relative to the Bayes rule.
  • Derive the deterministic approximate-ERM comparison from a uniform deviation event.

Training loss is a sample-dependent score; risk is performance on a fresh example from a specified population. Confusing these quantities hides both overfitting and limitations of the chosen hypothesis class. Statistical learning theory starts by naming the distribution, loss, reference class and algorithm. Only then can a statement about excess risk explain what a learned predictor has actually achieved.

Population averages and observed averages

Let Z=(X,Y) have distribution P, and let a measurable loss evaluate a predictor h on an example z. The population risk is its expectation on a fresh Z. Given n independent identically distributed training examples, empirical risk averages the losses on those particular observations. For a predictor fixed before seeing the sample, empirical risk is an unbiased estimate of risk when the expectation exists. A predictor selected using the sample is random and may exploit favorable sample fluctuations, so that unbiasedness does not automatically survive selection.

To keep the probability statements below ordinary and measurable, assume finite or countable classes with measurable predictors and losses, or explicitly assume any uncountable supremum and learning rule used is measurable. The elementary uniform bounds will additionally impose bounded losses when needed. Merely writing an integral does not ensure finite risk for an unbounded loss, and a zero training error does not identify the population distribution. Evaluation on independent fresh data changes which random variables are being averaged, rather than converting the original training average into an unbiased certificate.

RP(h)=EZ∼Pℓ(h,Z),R^S(h)=1n∑i=1nℓ(h,Zi),Z1,…,Zn∼iidPR_P(h)=\mathbb E_{Z\sim P}\ell(h,Z),\qquad \widehat R_S(h)=\frac1n\sum_{i=1}^n\ell(h,Z_i),\qquad Z_1,\ldots,Z_n\overset{\mathrm{iid}}\sim P
Risk uses a fresh population draw; the empirical average depends on the realized training sample.↔ Scroll wide equations horizontally.

Choose the comparator before measuring excess

The best risk within a class is the infimum over that class; it need not be attained unless additional conditions provide a minimizer. The Bayes risk takes the infimum over all admissible measurable predictors. Class excess risk measures learning relative to the chosen class, while Bayes excess also includes the class’s approximation error. A constant classifier can be learned perfectly within the two constant rules and still be far worse than a rule that uses X. No amount of optimization within the constant class removes that representational limitation.

For binary zero-one loss, the Bayes rule predicts the more likely label at each input, with a fixed convention for ties. Its conditional error is the smaller of the two conditional label probabilities. This reasoning does not assume labels are deterministic. The difference between best class risk and Bayes risk is nonnegative and distribution dependent. A theorem that only compares to the class should not be advertised as recovery of the Bayes rule unless the approximation term is separately controlled, for example by a sequence of increasingly rich classes.

RP(h^)−RP∗=[RP(h^)−inf⁡h∈HRP(h)]+[inf⁡h∈HRP(h)−RP∗]R_P(\widehat h)-R_P^*=\left[R_P(\widehat h)-\inf_{h\in H}R_P(h)\right]+\left[\inf_{h\in H}R_P(h)-R_P^*\right]
The first term is excess risk within H; the second is approximation error relative to the Bayes risk.↔ Scroll wide equations horizontally.

A deterministic bridge from fit to risk

Suppose a realized sample satisfies a uniform deviation bound Delta across the class. Suppose the algorithm returns a predictor whose empirical risk is at most the class infimum plus an optimization tolerance eta. Add and subtract the empirical risks of the returned predictor and a comparator. Each population-to-sample difference costs at most Delta, while approximate empirical minimization costs eta. Taking comparators approaching the population infimum gives class excess at most two Delta plus eta, without assuming a population minimizer exists.

This comparison is deterministic once the sample event holds. A later concentration theorem supplies a probability for that event. The separation is useful: improving an optimizer reduces eta, restricting a class may reduce the fluctuation Delta, and enriching the class may reduce approximation error. These effects need not move in the same direction. Reporting only the smallest training loss suppresses the quantities needed to decide whether a better fit is likely to improve fresh-sample performance.

A perfectly learned class can still be restrictive

Inputs a,b,c have probabilities 0.5,0.3,0.2, and positive-label probabilities 0.9,0.4,0.1. For zero-one loss compare the Bayes rule with the class consisting only of the two constant classifiers.

  1. The Bayes rule predicts positive at a and negative at b,c. Its risk is 0.5(0.1)+0.3(0.4)+0.2(0.1)=0.190.5(0.1)+0.3(0.4)+0.2(0.1)=0.19.

  2. The constant-positive risk is 0.5(0.1)+0.3(0.6)+0.2(0.9)=0.410.5(0.1)+0.3(0.6)+0.2(0.9)=0.41. The constant-negative risk is 0.5(0.9)+0.3(0.4)+0.2(0.1)=0.590.5(0.9)+0.3(0.4)+0.2(0.1)=0.59.

  3. A training sample with three positive labels and two negative labels gives empirical risks 0.4 and 0.6, so exact ERM chooses constant positive. Its class excess is zero, while its Bayes excess is 0.41−0.19=0.22.

The result

The selected rule is optimal within the constant class but still has approximation error 0.22. The particular sample fit does not remove that restriction.

Explore the model

Interactive lab

Interactive lab · sampling

Risk of a predictor fixed in advance

Pause and Reset, then set Bernoulli error probability p = 0.20 and sample size n = 50. Interpret K/n as empirical zero-one loss of one predictor fixed before sampling. Predict mean 0.20 and variance 0.20·0.80/50=0.0032. Reset and set both p = 0.20 and n = 100 to halve the variance. The instrument gives a fixed-predictor sampling distribution, not the distribution after selecting the best of many predictors.

Risk of a predictor fixed in advanceExact binomial masses for the mean of n independent Bernoulli trials, compared with normal mass between adjacent half-count boundaries; normal tails outside the finite support remain outside the bars. Playback highlights outcomes, not random samples. The Berry–Esseen bound applies to standardized CDFs, not individual bars or continuity-corrected errors. At p = 0 or 1, normal comparison and that bound are disabled. Normal-CDF evaluation uses a numerical approximation with absolute error below 7.5×10⁻⁸ (at most 1.5×10⁻⁷ per interval, before rounding). Current readings: Mean sample proportion: 0.5; Sample-mean variance: 0.0125; Uniform CDF error bound: ≤ 0.1062. All parameters are adjustable with the labeled controls below.Exact distribution of the mean of 20 independent Bernoulli variables with success probability 0.5; playback highlights outcome 0.00.250.50.75100.0580.1150.1730.23Sample mean · k / nProbability massNormal bin masses are an approximationk = 0 · exact probability = 9.54e-7
Exact binomial massNormal interval massHighlighted outcome / mean
Mean sample proportion
0.5
Sample-mean variance
0.0125
Uniform CDF error bound
≤ 0.1062
t = 0 s

Exact binomial masses for the mean of n independent Bernoulli trials, compared with normal mass between adjacent half-count boundaries; normal tails outside the finite support remain outside the bars. Playback highlights outcomes, not random samples. The Berry–Esseen bound applies to standardized CDFs, not individual bars or continuity-corrected errors. At p = 0 or 1, normal comparison and that bound are disabled. Normal-CDF evaluation uses a numerical approximation with absolute error below 7.5×10⁻⁸ (at most 1.5×10⁻⁷ per interval, before rounding). Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forA model chosen from the same sample needs a selection-aware argument beyond fixed-predictor unbiasedness.

Check your understanding

An algorithm has zero excess risk within H, but infimum risk in H exceeds Bayes risk by 0.12. What is its Bayes excess?

Try it yourself

On a realized uniform-deviation event with Delta=0.03, an algorithm is an eta=0.01 approximate empirical minimizer. If best class risk is 0.18 and Bayes risk 0.10, bound its risk and its Bayes excess.

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Use two population-to-empirical comparisons and add the optimization tolerance before adding approximation error.

Compare with the solution

Class excess is at most 2(0.03)+0.01=0.072(0.03)+0.01=0.07, so the returned risk is at most 0.25. Approximation error is 0.18−0.10=0.08, giving Bayes excess at most 0.07+0.08=0.15. These are consequences on the specified sample event, not unconditional probability statements. They also show why class excess and Bayes excess must have different names: the same learned predictor has a 0.07 estimation-and-optimization certificate yet a 0.15 Bayes comparison once its class restriction is included.

Take it with you

  • Risk refers to a stated population and a fresh example.
  • Class excess and Bayes excess differ by approximation error.
  • Uniform deviation Delta and optimization tolerance eta imply class excess at most 2Delta+eta.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.