Course contents · Next: empirical risk and generalization
Source: Lectures 0-9, pp. 6-31.
1. Prediction, loss, and risk
Lecture 0; pp. 6-8.
We observe training data and want to predict after observing a new input . Assume the training pairs and test pair are independent draws from the same unknown distribution on .
This assumption connects past observations to future predictions. One input can have several possible outcomes: its label need not be deterministic.
- Classification: is finite, such as digit labels or traffic signs.
- Regression: or another continuous output space.
- Uncertainty quantification: output probabilities or a set of plausible outcomes.
A loss measures the cost of predicting when the outcome is . The population risk is
For a fitted predictor, is random through the training data. An outer expectation averages over that randomness.
Linear regression as the first example
For , let have rows and let . Least squares solves
Differentiating gives
If is invertible, . Otherwise solve the normal equations with a suitable generalized inverse. Predict with .
Why squared loss? Write . For finite conditional second moments,
The cross term vanishes because . Thus the unrestricted population minimizer is . Restricting to linear functions introduces an approximation choice.
The statistical issue remains: minimizing observed average loss need not minimize its population expectation. This becomes the ERM question in Part 2.
Other outputs
Logistic regression uses and predicts 1 when . Part 3 explains how its parameters are fitted.
Quantile regression estimates a conditional quantile. Two such estimates can form an interval . Estimated probabilities or quantiles alone do not automatically provide a coverage guarantee; Part 4 develops conformal calibration.
2. The Bayes classifier
Lectures 1-2; pp. 9-13.
Under 0-1 loss, , risk is
For binary labels, set . By the tower property,
At a fixed input, the two conditional errors are
Choose 1 exactly when , or . Therefore
This minimizes conditional risk at every input; averaging proves for every classifier. The Bayes risk is
If , even the optimal prediction has conditional error .
Multiclass and unequal costs
For classes , predicting has error . Choose the largest conditional probability.
For a general cost function, choose
Confusing a stop sign with a speed-limit sign can cost more than confusing two speed limits. The optimal rule changes with the loss.
Bayes’ rule and the lecture examples
With class prior and class-conditional density ,
The denominator is common to every class, so compare directly. For the PDF’s discrete example:
| Input | ||||||
|---|---|---|---|---|---|---|
| 0 | 0.1 | 0.2 | 0.5 | 0.8 | 0.9 | |
| 0.9 | 0.3 | 0.1 | 0.3 | 0.1 | 0.3 | |
| 1 | 1 | 0 | 0 | 0 | 0 |
These are unnormalized joint scores. Normalization cancels, so each column selects its larger score.
For , predicting 1 means
Taking logs and collecting terms gives
Different variances produce a quadratic boundary. Equal variances cancel the terms, leaving a linear boundary. This leads to QDA and LDA in Part 3.
3. Plug-in classifiers and excess risk
Lecture 3; pp. 14-15.
Estimate the unknown with and set
Step 1: express excess risk pointwise
Compare the conditional errors of and :
- If , the difference is zero.
- If , it is .
- If , it is .
Thus
Disagreement matters most where one class is clearly favored.
Step 2: bound disagreement by estimation error
Let . Disagreement puts and on opposite sides of :
When the rules agree, the excess-risk integrand is zero. Therefore
Apply this conditionally on with , then average over training data:
Vanishing average absolute estimation error implies convergence to Bayes risk. It does not require agreement with Bayes at every input.
4. Local averages and consistency
Lectures 3-5; pp. 15-20.
Notions of consistency
For a fixed distribution:
Universal means the corresponding property holds for every distribution on the stated space. Since , dominated convergence shows that strong consistency implies consistency in expectation.
The lecture analogy is mean estimation: the sample mean converges almost surely for every distribution with finite first absolute moment. A sample median estimates a median and is not universally consistent for the mean.
Weighted label estimators
On , consider
Weights may depend on , but not on the labels.
Kernel smoothing: with bandwidth ,
Histograms: partition space into cubes of side length . Let contain and . Use
Nearest neighbors: give weight to each of the nearest observations and zero to the rest. Resolve distance ties without using labels.
Stone’s theorem
Suppose the normalized, nonnegative weights satisfy:
-
Stability: for a constant and every nonnegative integrable ,
-
Localization: for every ,
-
Vanishing maximum weight: .
Then , so the classifiers are universally consistent.
Derivation: separate smoothing error from label noise
Define . Then
First suppose is Lipschitz with constant . Separate neighbors within distance from those farther away. Since ,
Take by localization, then .
Now allow measurable . Choose bounded Lipschitz with , and let . Triangle inequality and stability give
For fixed , the final term vanishes by the Lipschitz argument. Then send .
Finally control label noise. Conditional on the inputs, are independent and centered, with variances at most . Thus
Taking expectations and using Cauchy-Schwarz,
This includes the noise calculation assigned as an exercise in the PDF.
Applying the conditions
For regular histograms, sufficient conditions are and : cells shrink while their typical sample counts increase. This interpretation is intuitive; the theorem does not require an input density.
For -NN, sufficient conditions are and . The maximum weight vanishes, while the decreasing sample fraction makes the neighbor radius shrink at almost every test input. A fixed does not average away label noise.
The lecture states these applications; verifying their geometric weight conditions is separate from Stone’s general proof. To strengthen expected-error convergence to almost-sure convergence, we next need concentration inequalities.
5. From limit theorems to concentration
Lectures 5-6; pp. 20-23.
For i.i.d. with mean , the strong law gives almost surely when . If , the central limit theorem gives
With , Berry-Esseen bounds the normal-approximation error:
Correction to p. 20: the third moment is centered and the denominator contains . Even this quantitative approximation can be too coarse when the tail probability of interest is smaller than its approximation error. Concentration bounds directly control finite-sample tails.
Markov and Chernoff
For and , . Taking expectations proves
More generally, apply Markov to a nonnegative increasing function with :
Taking , , gives for any real
Minimize over to obtain the Chernoff bound. Its usefulness depends on controlling the moment-generating function.
Sub-Gaussian sums
A centered variable is sub-Gaussian with parameter if
The parameter bounds tail behavior and need not equal the actual variance. Suppose independent centered have parameters , and set . Independence gives
The derivative of the exponent is , so its minimizer is . Substituting yields
Apply the same argument to and add the tail bounds:
For a common parameter , the exponent is .
Hoeffding’s lemma and inequality
If , convexity puts the exponential below its endpoint chord:
The resulting bound on the centered moment-generating function is Hoeffding’s lemma:
One way to finish the chord argument is to use its two-point distribution at . Its log moment-generating function has after centering. The second derivative is a variance under exponential reweighting, bounded by . Integrating twice gives .
Thus is sub-Gaussian with parameter . Substitution into the sum bound proves, for independent ,
The variables need not be identically distributed.
Bernstein’s inequality
Hoeffding uses ranges. Bernstein also uses variance. For independent centered with , let and . Then
The PDF states this result. Its connection to Chernoff can be seen from the following calculation. For , expand the exponential. Since , , and for ,
Multiply these bounds and apply Chernoff. Choosing gives the displayed result when ; is deterministic. Replacing with gives the sample-mean version.
Small variance can improve the bound, but the comparison with Hoeffding also depends on . There is no variance threshold that makes Bernstein uniformly better for all deviations.
6. Martingales and bounded differences
Lecture 7; pp. 24-25.
Our estimator is a function of independent observations, not usually a sum of independent terms. Martingales extend concentration to this setting.
A martingale is integrable, depends on information available by step , and satisfies
Its increments have conditional mean zero. Independent centered partial sums are an example.
Hoeffding-Azuma
Suppose each , given the past, lies in an interval of deterministic length . Conditional Hoeffding’s lemma gives
Repeated conditioning replaces the independence step used earlier:
Chernoff minimization with gives
Here is an interval width. If the assumption is instead , use width .
McDiarmid’s inequality
Let be independent. Suppose replacing coordinate changes by at most :
Define the Doob martingale
Given the first observations, changing changes the conditional expectation over future observations by at most . Thus has conditional range of width at most . Since , Hoeffding-Azuma gives
For with , choose . This recovers Hoeffding exactly.
7. Examples, high probability, and almost-sure convergence
Lecture 8; pp. 25-27.
Binomial count
If with independent , then . The one-sided Hoeffding bound at sample-mean threshold gives
Heavy tails and a bounded transformation
For Cauchy observations, the mean is undefined, so the preceding sub-Gaussian and bounded-sum assumptions fail. The density decays like ; the tail probability decays like .
Nevertheless changes by at most 2 when any coordinate changes. McDiarmid applies with :
The bound is valid but becomes uninformative as grows. A bounded output alone does not imply useful concentration.
If instead , use , obtained by integrating the derivative . Then , giving the much stronger Hoeffding-sized exponent.
Convert a tail bound into a confidence statement
Suppose . Set the right side equal to :
Thus, with probability at least , the deviation is at most this threshold.
Borel-Cantelli
If , only finitely many occur almost surely. Independence of the events is not required for this direction.
For example, if and , then almost surely only finitely many of the equal 1.
To prove convergence of bounded sample means, suppose , the observations are independent with common mean , and
Choose for . Then and
Borel-Cantelli implies eventually almost surely, proving convergence. This proves the strong law in the bounded setting; the general strong law is broader.
8. Strong consistency of histogram classifiers
Lectures 8-9; pp. 27-31.
We return to the original learning problem. For deterministic regular histogram bins, assume and . The lecture proves universal strong consistency by replacing a random denominator with a deterministic one for analysis.
Step 1: rewrite the decision
In a nonempty cell, predicting 1 means
Since , this is equivalent to
Let . Divide both sides by and define
Cells of zero -mass do not affect risk. In empty cells both scores are zero, so either label is an allowable maximizer, including the earlier fallback. These scores are proof devices: the classifier does not need to know .
Step 2: extend the excess-risk bound
Write and . If the chosen label differs from a Bayes label , then . Therefore
When the labels agree the excess is zero. Integrating gives
It suffices to show each term vanishes almost surely.
Step 3: control the expectation
Focus on . Decompose
Here is the expectation argument underlying the adaptation mentioned in the PDF. Let . Then
The first term vanishes by approximating with bounded Lipschitz functions: cell averaging contracts error, and a Lipschitz function varies by at most within a cell.
For the second term, in a cell of mass , is unbiased for , and
Thus the cell’s integrated expected error is at most . In any fixed bounded box, the number of intersecting cells is , so Cauchy-Schwarz gives
Outside those cells, nonnegativity and unbiasedness bound the integrated error by twice the probability mass outside the box. Take , then enlarge the box to make that mass vanish. Therefore without assuming an input density.
Step 4: concentrate around the expectation
Replace one training pair by . Triangle inequality bounds the change in by
The first integral equals : on the cell containing , its probability mass cancels the denominator. The second is . Hence the change is at most .
McDiarmid now gives
Choose with . The failure probabilities are at most and are summable. Borel-Cantelli implies almost surely. Together with Step 3, almost surely.
The class-0 term follows by replacing with . Step 2 then proves almost surely for every input-label distribution.
We have learned by estimating local probabilities. The next lectures ask whether we can instead minimize observed classification error directly: continue to Part 2.