TL;DR

  1. Now is unknown; we see training points drawn i.i.d. from . The goal is a function with .
  2. An algorithm is consistent for if for every , and universally consistent if this holds for every (Stone 1977: kNN). Consistency is about the risk, not about .
  3. The empirical risk converges to for every fixed (law of large numbers, Proposition 6). ERM picks .
  4. ERM is not always successful: a function that memorizes the training points has but . The LLN does not apply because depends on all data points.
  5. The excess risk splits into estimation error (random, grows with the size of ) and approximation error (deterministic, shrinks with the size of ). Classical regime: U-shaped test risk. Modern regime: interpolation, double descent. For the loss, pointwise: .
  6. No Free Lunch: averaged over all possible true functions, all classifiers perform the same. Machine learning without an inductive bias is impossible.

Exam relevance

  • Multiple choice (task 1 of the real exam, task 2 of the mock): what consistency means and what it does not mean, universal consistency (kNN), which error term is random, over- vs. under-parameterization, what NFL does and does not say. The mock asked exactly such statements; see the MC block below.
  • Table tasks: empirical risks from a small sample, the ERM choice, estimation and approximation error from given true risks, bias and variance from a few predictions. Worked examples: ERM task, bias-variance task, NFL task.
  • Sheet 2, Exercise 2 is the NFL on (kNN vs. memorize-or-zero, averaged over all target functions).

Overview: 1. The finite sample setting and consistency, 2. Estimating the risk by the empirical risk, 3. Empirical risk minimization and why it can fail, 4. Estimation and approximation error, 5. The bias-variance decomposition, 6. The No-Free-Lunch theorem.

Predicting in the finite sample setting

Finite sample setting and the training data

Slides 105-108

So far we discussed the “optimistic” regime in which we know the underlying distribution: then there is nothing to learn. Now we turn to the standard machine learning setting: we do not know the distribution, but we see samples from it (Bach Sec. 2, Devroye et al. Sec. 2, Hastie et al. Sec. 2.4-2.9). Everything we do has an attached uncertainty that depends on how well the sample represents .

Training data

We draw training points i.i.d. (independent and identically distributed) according to .

The i.i.d. assumption makes a lot of sense in many cases (to some degree even for blocks of text in language model pre-training), and it lets us use many tools from statistics. But it is a strong assumption in many applications: time series (today’s weather depends on yesterday’s), patients from the same hospital or family, repeated measurements of the same person. A second issue the framework does not cover: different train and test distributions (a model trained on data from one hospital, used in another).

The goal of machine learning

Slide 109

Goal

Given training points, construct a function whose true risk is close to the Bayes risk: .

depends on the random sample, so is a random variable. To make “close” precise we need convergence of random variables.

Recap: convergence of random variables

Slide 110

Three modes of convergence

Let be random variables and a random variable. converges to

  • in probability if
  • almost surely (a.s.) if
  • in / in expectation if

Almost sure convergence implies convergence in probability, convergence implies convergence in probability, and there are no other implications in general.

Consistency of a learning algorithm

Slides 111-113

Consider an infinite sequence of data points drawn i.i.d. from , and let be the function the algorithm constructs from the first points.

Consistency

  • is consistent (for ) if the risk of converges to the Bayes risk in probability:
  • With almost sure convergence instead, is strongly consistent.
  • is universally consistent if it is consistent for all distributions on .

Universal consistency

No matter what the distribution is, after “enough data points” the true risk of is arbitrarily close to the best possible risk. This is what we ultimately want.

What consistency does not say

  • It is about the convergence of the risk , not about the function: need not converge to (pointwise or otherwise). Two very different functions can have the same risk.
  • It is an asymptotic statement. It gives no rate: how many points are “enough” depends on , and for every fixed there are distributions for which is still far from .

For a long time it was unknown whether universally consistent algorithms exist at all. The first positive answer came in 1977, when Stone proved that the kNN classifier is universally consistent (with and ; with a fixed , for example , the noise of the nearest neighbour’s label never averages out). Since then, many algorithms have been shown to be universally consistent: support vector machines, boosting, random forests and more. Understanding the principles behind such results is a large part of this course.

Why not use the plug-in classifier and be done?

Slide 114

Idea: estimate the regression function by some from the training data and plug it into the Bayes classifier:

  • In theory: with a suitable estimator , the plug-in approach is universally consistent. ☺
  • In practice: estimating densities is notoriously hard, in particular in high-dimensional input spaces. We would need a ridiculous amount of training data, so the plug-in approach is useless in practice. ☹

Estimating the true risk by the empirical risk

Empirical risk

Slides 115-118

We defined the best classifier as the one that minimizes the true risk. Without we cannot compute the true risk. The obvious idea: estimate the risk from the sample and pick the function with the smallest estimated risk. The big question is whether this is (always? sometimes?) successful. First we look at how to estimate the risk of a fixed, given function .

Empirical risk

It can be computed from the training points alone. For the 0-1 loss it is the fraction of misclassified training points.

Is it a “good” estimate? A formal way to say this: converges to as .

Recap: law of large numbers

Slides 119-121

Proposition 5 (law of large numbers, simplest version)

Let be independent random variables drawn from a distribution with expectation . Then (under mild assumptions)

Mini example: why independence is crucial

Let be the toss of a fair coin and identical copies of . Each is with , but they are not independent. Depending on , the empirical average is always 0 or always 1, so it never converges to .

“Mild assumptions”: there are many versions of the LLN. Often it is stated for random variables with finite variance, which makes the proof much simpler, but it also holds as long as the expectation exists. The do not even need to be identically distributed, as long as they have the same expectation.

Convergence of the empirical risk of a fixed function

Slides 122-124

Proposition 6 (empirical risk converges for a fixed function)

In the standard setup, fix a function . Then for this fixed

What it means, and what not

  • For each fixed function, the training error is a good estimate of the test error when is large.
  • It says nothing about how fast (no rate), and nothing about a function that was chosen using the data. That is exactly what a learning algorithm does, and it is the limitation that the next sections run into.

Empirical risk minimization

The ERM principle

Slides 125-127

For a fixed , the empirical risk converges to the true risk. So to find (which minimizes the true risk), it makes sense to pick the function that minimizes the empirical risk and hope that it is close.

Empirical risk minimization (ERM)

  • Define a set of functions .
  • Choose a function with the smallest empirical risk:

It might not be unique. For simplicity we assume the minimizer exists (otherwise one argues with a sequence approaching the infimum).

The function class is the important “parameter” of ERM: all linear functions, all decision trees of depth 5, all random forests, all two-layer MLPs, …

”Classical” regime vs. “modern” regime

Slide 128

Two regimes

  • Classical regime: the function class does not allow for interpolation.
  • Modern regime / interpolation regime: is so large that the training data can be interpolated (fitted with training error 0).

Is ERM always successful?

Slides 129-132

In our framework, a “successful” classifier is a consistent one. So: does ERM always converge?

Counterexample (slide 130)

  • with the uniform distribution. Labels are deterministic: for and for .
  • Draw training points. Define : on the training points, predict the training label; on all other points, predict .
  • Then but for all (the set of training points has probability 0, so predicts almost everywhere and is wrong on the right half).
  • With : always, but .

Why can’t we use the LLN? The key property in the LLN is independence. Here , but depends on all data points . So even though the points are independent, the are not: they all depend on .

Trap

Slide 129 writes the question as ”?“. This is the gap between training and test error of the selected function. The consistency question is . In the counterexample both fail: the gap stays , and .

Preview: statistical learning theory

It is not true that the minimizer of the empirical risk always converges to the Bayes classifier. Is machine learning doomed? No: statistical learning theory (Lecture 3) gives conditions on under which ERM works after all.

ERM in practice

Slide 133

  • Conceptually, ERM is a straightforward learning principle. The key to its success or failure is choosing a “good” function class : explicitly (classical regime) or implicitly (interpolation regime, sometimes).
  • Computationally it can be hard: finding the minimizer of the 0-1 loss is often NP hard. This is why in practice we use convex relaxations of the 0-1 loss: the surrogate losses of Lecture 1.1.

Estimation and approximation error

Definitions

Slides 134-135

When we perform ERM we can make two types of error. Let be the true best function in .

Estimation and approximation error

  • Estimation error : a random variable that depends on the sample.
  • Approximation error : a deterministic quantity that does not depend on the sample, only on the choice of .

Decomposition of the excess risk

Sketch: the set of all functions contains F; inside F, f_n (learned) and f-tilde (best in F); f* (Bayes classifier) lies outside F. Estimation error between f_n and f-tilde, approximation error between f-tilde and f*
Slide 135: estimation error inside 𝓕, approximation error from 𝓕 to the Bayes classifier.

Task: ERM, estimation and approximation error

Exam-style task: ERM on a small sample (4 P)

is uniform on with given below. with threshold classifiers iff . The training sample is

1234
0.10.60.30.9

(a) (1 P, easy) Compute for all (0-1 loss). Which function does ERM select?

(b) (1.5 P, harder) Compute the true risks, , and the estimation and approximation error of ERM.

(c) (1.5 P, transfer) Now let be all functions . What happens to the approximation error, and what can happen to the estimation error?

The classical regime

Slides 136-138

In the classical regime, is reasonably small (no interpolation). Then the two errors behave in opposite ways as grows:

Two curves over the size of the function class: one decreasing, one increasing
Slide 136: which one is which? The decreasing curve is the approximation error, the increasing one the estimation error. The true risk (their sum plus R*) is U-shaped.
True quadratic function with noisy training points, a linear fit (underfitting) and a wiggly polynomial fit (overfitting)
Slide 137: true function quadratic, 𝓕 = linear functions (red, underfitting) or all polynomials (blue, overfitting).

Overfitting and underfitting (classical regime)

  • Overfitting: is very large, so some explains all training points very well or exactly. Such a function tends to be complicated and models the noise as well, so predictions for unseen points are poor (large test error). Low approximation error, high estimation error.
  • Underfitting: the model is too simple, is too small. The estimated functions are stable with respect to noise, but cannot represent the truth. Large approximation error, low estimation error.

The modern regime and double descent

Slides 139-141

In the modern regime the function class is huge and covers pretty much all possible functions.

  • The empirical risk minimizer interpolates the training points ( has training error 0).
  • The approximation error is often close to 0: the functions can represent almost anything.
  • Traditional reasoning predicts a huge estimation error because of overfitting.
  • But some algorithms always find solutions that interpolate and generalize well; these have a small estimation error. Practice shows that overfitting can even be beneficial.

There exist many functions with training error close to 0. Most of them would not generalize, some might. The question is how to find those.

F is approximately all functions; many functions with very small training error; f_n learned by the algorithm and the Bayes classifier f* inside
Slide 139: modern regime, 𝓕 ≈ all functions.
Left: classical U-shaped test risk over the capacity of H. Right: double descent, the test risk rises to a peak at the interpolation threshold and falls again in the over-parameterized regime
Slide 141: the classical U-curve (A) and the double descent curve (B). Figure from Belkin et al., PNAS 2019.

Double descent

Below the interpolation threshold the classical picture holds. At the threshold the model is just able to fit the data and the test risk peaks. Beyond it, in the over-parameterized regime, the test risk falls again, often below the classical sweet spot. Why this can work is the topic of Lecture 8.

The bias-variance decomposition

Bias-variance tradeoff in L2 regression

Slides 142-147

Another decomposition of the error is most simple for regression with the squared loss. Let be constructed from random sample points and the regression function. For a fixed point , with the expectation over the random draw of the sample:

Bias-variance decomposition

  • Variance term: the variance of the random variable .
  • Bias term: how much and deviate.

For every loss we have "" in this spirit, but for the loss we get equality (as in Proposition 3).

Intuition

  • Variance has the same intuition as the estimation error: it depends on the random data and on the capacity of .
  • Bias has the same intuition as the approximation error: it does not depend on the data, only on the capacity of .

The classical picture (slide 147): as model complexity grows, the bias falls, the variance rises, and the test error is U-shaped.

Error against model complexity: bias decreasing, variance increasing, test error U-shaped
Slide 147: the classical bias-variance figure.
The example of slide 137 as a simulation: noisy samples of a quadratic function, fitted by polynomials of degree d. The faint lines are fits to 30 different samples, their spread is the variance, the gap between their mean and the truth is the bias. Move the degree and the number of points.

Task: bias and variance from predictions

Exam-style task: bias and variance at one point (4 P)

An algorithm is trained on four independent training sets. At a fixed point it predicts (each with probability ). The true regression function is .

(a) (1 P, easy) Compute the bias term and the variance term.

(b) (1.5 P, harder) Verify the decomposition. Then use the shrunk predictor : bias, variance and expected squared error?

(c) (1.5 P, transfer) Which shrinkage factor minimizes the expected squared error of at ? What does this say about bias and variance?

The No-Free-Lunch theorem

Intuition and setup

Slides 148-151

(Presentation after Ho and Pepyne 2002; see also Shalev-Shwartz and Ben-David Sec. 5.1 and Devroye et al. Chapter 7.)

Intuition

There is no single best classifier that outperforms all other classifiers when averaged over all possible learning problems. There are many formal versions; the lecture uses the easiest one.

NFL setup

  • The input space is a finite set with a fixed distribution, say uniform (the proofs work for all distributions).
  • Binary classification, , and the labels are deterministic functions of the input.
  • There are functions ; call the set of all of them .
  • One of them, , is the true function; we observe noise-free training points and an algorithm estimates .
  • Table: rows are the estimated functions , columns the true functions , and the entry is the true 0-1 error of when the true function is .

With the uniform distribution, is the fraction of points where and disagree.

Trap

The bullet text on slide 151 says “rows = true functions, columns = estimated functions”, the drawing and the definition of use the other orientation. The statements below hold either way: they only count how many functions disagree with a given one on points.

Propositions 7 to 9

Slides 152-155

Proposition 7 (the risk in each row is the same)

In each row of the table, each risk value occurs the same number of times.

Proposition 8 (simple NFL)

On average over all true functions , the performance of all classifiers is the same.

Proof: obvious consequence of Proposition 7 (every row has the same multiset of values, so the same average).

Proposition 9 (simple NFL with training data)

Given a training set : on average over all true functions that could have generated the training data, all estimated classifiers with 0 training error perform the same.

The table of slide 151 for m = 3. Pick a true function and training points: inconsistent columns and rows with training errors fade out, and all remaining rows have the same average. Then switch on the inductive bias and watch the averages differ.

Task: No Free Lunch on three points

Exam-style task: NFL (4 P)

with the uniform distribution, labels . The only training point is . Classifier A predicts everywhere. Classifier B predicts at and at and . Write functions as label triples, for example .

(a) (1 P, easy) List all true functions consistent with the training data.

(b) (1.5 P, harder) Compute the average true error of A and of B over these functions.

(c) (1.5 P, transfer) Assume the inductive bias “similar inputs, similar labels”: along the label changes at most once. Recompute the averages and explain the difference.

Discussion

Slides 156-159

We have seen that “the best possible classifier for all data sets” does not exist. Should we give up? Is machine learning meaningless?

No: machine learning needs an inductive bias

  • In practice we do not consider all possible functions. As soon as we make assumptions on the function space (or even just exclude pathological functions), the NFL breaks down: assumptions restrict the set of possible true functions, which deletes columns from the table, and the proof breaks down.
  • Example: a notion of similarity among the inputs , and only functions that give similar labels to similar points. This excludes functions that look as if they distribute labels randomly.
  • Machine learning without an inductive bias is impossible!

Much more general theorems exist, for example for data drawn from a joint distribution on with any space (Wolpert 1996, Ho and Pepyne 2002, Devroye et al. Chapter 7).

Summary

ConceptDefinitionKey point
Consistencyabout the risk, asymptotic, no rate
Universal consistencyconsistent for every exists: kNN (Stone 1977), SVM, boosting, random forests
Empirical risk for a fixed (LLN)
ERMcan fail: depends on the data
Estimation errorrandom, grows with
Approximation errordeterministic, shrinks with
Variance / bias () / same intuition as estimation / approximation
No Free Lunchaveraged over all true functions, all classifiers equallearning needs an inductive bias

Self-Test

Multiple Choice

References