CS 460G Midterm Hub / Lectures / Week 2 Lecture 1
Week 2 · Lecture 1

Learning Theory I — Empirical Risk Minimisation

Loss, risk, empirical risk, and the definition of the learning algorithm.

short answermath

This is the single most-quoted deck in short-answer questions. The formula chain loss → risk → empirical risk → ERM is the answer to "What is Empirical Risk Minimization? Why the term empirical?" and it recurs in the SVM and regularisation decks.

The learning problem, formally

Given a domain set $\mathcal{X}$, a label set $\mathcal{Y}$, and a joint distribution $P(x,y)$ over $\mathcal{X}\times\mathcal{Y}$:

  • input $x \in \mathbb{R}^d = \mathcal{X}$
  • output $y \in \{-1,+1\}$ for binary classification
  • unknown target function $f:\mathcal{X}\to\mathcal{Y}$, the true relationship between $x$ and $y$
  • data $D = \{(x_1,y_1),\dots,(x_N,y_N)\}$
  • a hypothesis set $\mathcal{H} = \{h_1,h_2,\dots\}$
  • a learning algorithm $A$ that picks $g \approx f$ from $\mathcal{H}$ using $D$
The learning problem — hypothesis set and learning algorithm
The learning problem — hypothesis set and learning algorithm · slide 33

$f$ cannot be known, so the best you can do is pick the hypothesis $g$ that best represents it on the data you have. Everything that follows is a way of making "best represents" precise.

The formula chain

This is the slide you should be able to reproduce verbatim.

Loss, risk, empirical risk and ERM together
Loss, risk, empirical risk and ERM together · slide 40

Loss — how wrong one prediction is:

$$L(\hat{y}, y) = \begin{cases} 1 & \text{if } \hat{y} \neq y \\ 0 & \text{if } \hat{y} = y \end{cases}$$

Risk — the expected loss over the true (unknown) distribution:

$$R(h) = \mathbb{E}[L(h(x), y)] = \int L(h(x), y)\, dP(x,y)$$

Empirical risk — the average loss you can actually compute:

$$R_{\text{emp}}(h) = \frac{1}{n}\sum_{i=1}^{n} L(h(x_i), y_i)$$

ERM — the learning algorithm defined by minimising it:

$$\hat{h} = \arg\min_{h \in \mathcal{H}} R_{\text{emp}}(h)$$

The slide notes explicitly that $R(h)$ cannot be computed because $P(x,y)$ is unknown — this is called agnostic learning. That sentence is the "why empirical" part of the answer, and it is worth a mark on its own.

Why the word "empirical"

Because the quantity being minimised is not the true risk $R(h)$ — it is the risk estimated from the empirical sample $D$. It is a finite-sample average standing in for an expectation over a distribution you never observe. The justification for that substitution is exactly what PAC learning (next lecture) formalises: under a finite $\mathcal{H}$ and enough i.i.d. samples, empirical risk minimisation is probably approximately correct.

Model answer — "What is ERM? Why the term empirical? Explain its role in learning theory." ERM is the principle of choosing the hypothesis $\hat h$ from a hypothesis class $\mathcal{H}$ that minimises the average loss on the training sample, $\hat h = \arg\min_{h\in\mathcal{H}} \frac{1}{n}\sum_i L(h(x_i),y_i)$. It is empirical because the true risk $R(h)=\mathbb{E}[L(h(x),y)]$ requires the unknown data distribution $P(x,y)$ and is therefore incomputable; the sample average is an empirical estimate of it. Its role in learning theory is to convert learning into a well-posed optimisation problem, and to serve as the object that generalisation theory bounds: PAC results show that for a finite hypothesis class, ERM on enough i.i.d. samples returns a hypothesis whose true risk is within $\epsilon$ of the best in $\mathcal{H}$ with probability at least $1-\delta$.

Probability vocabulary you are assumed to have

  • Sample space — the set of all possible outcomes of an experiment.
  • Random variable — a mapping that assigns a real number to each outcome ($\text{Head}\to 1$, $\text{Tail}\to 0$).
  • Discrete vs continuous — separate distinct values (a die, a coin) versus real numbers in an interval (weight, temperature).
  • Joint $P(X,Y)$; conditional $P(X\mid Y)$.
  • i.i.d. — random variables are independent and identically distributed iff they are mutually independent and share the same distribution.
Joint, conditional, and the definition of IID
Joint, conditional, and the definition of IID · slide 20

The running example

Every deck uses the same patient:

FieldValue
GenderF
Age80
Hypertension0
Heart disease1
Smoking historynever
BMI25.19
HbA1c6.6
Blood glucose140
Diabetic?

The inputs are the independent variables; Diabetic is the dependent variable. There is no closed-form diagnosis formula — but hospitals hold many such records, so "there must exist some pattern, we don't know it". That is the premise of supervised learning in one sentence.