Lecture 9: Approximation/Estimation Error and ERM
Stanford CS229 lecture 9 notes: Approximation/Estimation Error and ERM.
- cs229
- machine-learning
- course-notes
On this page
This is the learning theory lecture. The question: can we say anything provable about when learning works?
Setting up#
- Data is drawn i.i.d. from some distribution .
- The training error (empirical risk):
- The generalization error (true risk):
We care about generalization error, but we can only measure training error.
Empirical Risk Minimization (ERM)#
Pick a hypothesis class (e.g., all linear classifiers). ERM chooses the hypothesis with the lowest training error:
Logistic regression, SVMs, and so on are all approximations of this (since minimizing 0-1 loss directly is hard).
Approximation vs Estimation error#
Define:
- = the best possible hypothesis overall (the "Bayes optimal" one)
- = the best hypothesis in our class
- = what ERM actually gives us from the finite data
Then we can break down the error:
- Approximation error: the penalty for restricting ourselves to . Bigger class means smaller approximation error.
- Estimation error: the penalty for having only finite data. Bigger class means larger estimation error.
This lines up with what we saw before: approximation error is bias, estimation error is variance.
Two tools: Union bound and Hoeffding#
Union bound:
Hoeffding inequality: if is the average of i.i.d. Bernoulli() variables, then
In plain words, the more samples you have, the exponentially less likely it is that your estimate is far off.
Uniform convergence (finite )#
Suppose has hypotheses. For one fixed , Hoeffding says its training error is close to its true error. Using the union bound over all hypotheses:
So with probability at least , all hypotheses have training error within of true error, as long as:
This is the sample complexity: how much data you need. The cool part is that it grows only with .
And then the ERM guarantee: with probability ,
meaning ERM is within of the best hypothesis in the class.
Infinite classes and VC dimension#
Linear classifiers have infinitely many hypotheses, so is useless. But a -parameter model can be treated as having effectively (some finite number) when computed on a computer with finite precision, which gives a sample complexity that's roughly linear in the number of parameters .
The proper tool is the VC dimension: the size of the largest set of points that the class can shatter (label in every possible way). For linear classifiers in , VC dimension is . The takeaway is that the number of examples you need scales roughly linearly with VC dimension.