MIT 6.790 — Lecture 11

PAC and VC Dimension

§ Probably Approximately Correct (PAC)

The result from the end of Lecture 10 inspires the following definition.

Definition. For ϵ>0\epsilon > 0 and δ∈(0,1)\delta \in (0, 1), a learning algorithm that takes training data D\mathcal{D} and outputs a hypothesis h^\hat{h} is (ϵ,δ)(\epsilon, \delta)-PAC if:

P(R(h^)−R(h∗)≤ϵ)≥1−δ,\mathbb{P}\left( \mathcal{R}(\hat{h}) - \mathcal{R}(h^*) \leq \epsilon \right) \geq 1 - \delta,

where, as before, we denote h∗:=arg min⁡h∈HR(h)h^* := \argmin_{h \in \mathcal{H}} \mathcal{R}(h).

Example. The result from Lecture 10 says that, if the risk function R(h)\mathcal{R}(h) has a loss function satisfying L(x,y)∈[0,1]\mathcal{L}(x, y) \in [0, 1], then the ERM learning algorithm is (2log⁡∣H∣+log⁡(2/δ)2∣D∣,δ)\left(2 \sqrt{\frac{\log |\mathcal{H}| + \log\left(2 / \delta\right)}{2|\mathcal{D}|}}, \delta \right)-PAC.

§ PAC-Learnable

Definition. A hypothesis class H\mathcal{H} is PAC-learnable if there exists a learning algorithm that takes training data D\mathcal{D} and outputs a hypothesis h^\hat{h} such that the following is true for any ϵ>0\epsilon > 0 and δ∈(0,1)\delta \in (0, 1).

There exists a constant mH(ϵ,δ)m_{\mathcal{H}}(\epsilon, \delta) such that, no matter what the data distribution, h^\hat{h} is (ϵ,δ)(\epsilon, \delta)-PAC whenever ∣D∣>mH(ϵ,δ)|\mathcal{D}| > m_{\mathcal{H}}(\epsilon, \delta).

Example. The result from Lecture 10 says that any finite hypothesis class H\mathcal{H} is PAC-learnable (assuming a bounded loss function). In particular, in this case we have mH=O(log⁡∣H∣+log⁡(1/δ)ϵ2)m_{\mathcal{H}} = O\left( \frac{\log|\mathcal{H}| + \log(1/\delta)}{\epsilon^2} \right).

The assumption of “bounded loss” in the above example actually turns out to be pretty much required.

Fact. If the loss function is unbounded, then it turns out almost nothing is PAC-learnable.

Justification: Let's consider the simplest nontrivial case: H={h1,h2}\mathcal{H} = \{h_1, h_2\}. Then consider the following distribution on D\mathcal{D}.

  1. (a)

    With very small probability pp, we sample (x,y)(x, y) for which L(h1(x),y)=M\mathcal{L}(h_1(x), y) = M and L(h2(x),y)=1\mathcal{L}(h_2(x), y) = 1, where M≫1M \gg 1.

  2. (b)

    With very large probability 1−p1 - p, we sample (x,y)(x, y) for which L(h1(x),y)=L(h2(x),y)\mathcal{L}(h_1(x), y) = \mathcal{L}(h_2(x), y).

Then no matter how large an mH(ϵ,δ)m_{\mathcal{H}}(\epsilon, \delta) we pick, we can set pp small enough so that D\mathcal{D} almost always hits case (b). Then it is impossible for the learning algorithm to learn that h2h_2 is the better hypothesis.

Thematically, the reason why unbounded loss leads to PAC-unlearnability is that unbounded nonnegative random variables can have means that are impossible to bound given only finitely many samples.

The conclusion, then, is that we might as well assume the loss function is bounded. We should also direct our attention to infinite hypothesis classes H\mathcal{H}, as all the finite ones are automatically PAC-learnable under this assumption.

§ Growth Functions: Motivation

From now on, we'll specifically consider the case when our hypotheses h∈Hh \in \mathcal{H} are binary classifiers h ⁣:X→{+1,−1}h \colon \mathcal{X} \to \{+1, -1\}. Even still, proving or disproving PAC-learnability for infinite hypothesis classes seems hard.

Remark. This subsection and the next will take a step back from PAC-learnability for a while. Just have trust that all of this setup will eventually prove itself incredibly useful for deciding whether an infinite hypothesis class is PAC-learnable or not.

Suppose mm is the size of our training data D={(xi,yi)}i=1m\mathcal{D} = \{(x_i, y_i)\}_{i = 1}^m. Then there are only so many ways a hypothesis h∈Hh \in \mathcal{H} can perform in the training process. The training data acts like an mm-question true-or-false exam, so there are at most 2m2^m ways a hypothesis h∈Hh \in \mathcal{H} could perform. Our learning algorithm should pick the hypothesis h^∈H\hat{h} \in \mathcal{H} that scores the highest.

But if two hypotheses {h1,h2}\{h_1, h_2\} score the highest… well, then we haven't learned enough. It's possible that our learning algorithm outputs h^=h1\hat{h} = h_1, whereas the true optimal hypothesis is h∗=h2h^* = h_2. And maybe on the real test data, the output h^\hat{h} performs horribly in comparison to h∗h^*. We'd have no way of knowing, because h^\hat{h} and h∗h^* performed the same in the training exam.

§ Growth Functions: Definition

To formalize the idea of multiple hypotheses ending up indistinguishable in training, it helps to count the number of possible ways a hypothesis h∈Hh \in \mathcal{H} can perform on our mm-question true-or-false exam.

Definition. Given a training set X=(x(1),…,x(m))∈XmX = (x^{(1)}, \dots, x^{(m)}) \in \mathcal{X}^m, let HX\mathcal{H}_X denote the set of all possible labelings of points in XX by some hypothesis in H\mathcal{H}; that is,

HX:={(h(x(1)),…,h(x(m)))∣h∈H}.\mathcal{H}_X := \left\{ \left(h(x^{(1)}), \dots, h(x^{(m)})\right) \mid h \in \mathcal{H} \right\}.

Definition. Define ΓH(m):=max⁡X∈Xm∣HX∣\Gamma_{\mathcal{H}}(m) := \displaystyle \max_{X \in \mathcal{X}^m} |\mathcal{H}_X| to be the growth function of H\mathcal{H}.

Example. In the worst case, we have ΓH(m)=2m\Gamma_{\mathcal{H}}(m) = 2^m for all mm. This represents the scenario in which multiple hypotheses are the highest-scoring, making it impossible to pick out a PAC hypothesis.

Remark. By definition, ΓH(m)>2m\Gamma_{\mathcal{H}}(m) > 2^m is impossible.

Problem. Determine the growth function of H:={x↦sgn(x−θ)∣θ∈R}\mathcal{H} := \{x \mapsto \mathrm{sgn}(x - \theta) \mid \theta \in \mathbb{R}\}.

Solution: Suppose the training set is x(1)<⋯<x(m)x^{(1)} < \dots < x^{(m)}, in that order. Then there are only ΓH(m)=m+1\Gamma_{\mathcal{H}}(m) = \boxed{m + 1} ways a hypothesis in H\mathcal{H} could label these points; one such way is pictured below.

Problem. Let H\mathcal{H} be the class of all two-dimensional linear classifiers. Compute ΓH(3)\Gamma_{\mathcal{H}}(3) and ΓH(4)\Gamma_{\mathcal{H}}(4).

Solution: The picture below demonstrates that ΓH(3)=8\Gamma_{\mathcal{H}}(3) = \boxed{8} and is achieved by any three points in general position.

Interestingly, ΓH(4)\Gamma_{\mathcal{H}}(4) does not equal 24=162^4 = 16. If the four points of our data set are taken to be the vertices of a square, then not all 242^4 labelings of those vertices are achievable by a linear classifier.

Infamously, as shown above, the XOR cannot be modeled by a linear classifier, and ΓH(4)=14\Gamma_{\mathcal{H}}(4) = \boxed{14} instead of 1616. (To prove this, we would have to check that no other arrangement of four points gives more than 1414 achievable labelings.)

§ VC Dimension

Shockingly, as the following theorem states, there are only two types of growth functions.

Theorem. (VC Dichotomy) For any hypothesis class H\mathcal{H}, either:

Remark. Note that this theorem is fundamentally a set-theoretic result! Nothing about its statement requires any mention of a probability distribution or machine learning at all.

This inspires the following definitions.

Definition. A training set X∈XmX \in \mathcal{X}^m is shattered by a hypothesis class H\mathcal{H} if ∣HX∣=2m|\mathcal{H}_X| = 2^m. The VC-dimension VC(H)\mathrm{VC}(\mathcal{H}) of a hypothesis class H\mathcal{H} is the size of the largest subset of X\mathcal{X} that is shattered by H\mathcal{H}.

Example. If H\mathcal{H} is such that ΓH(N)=2N\Gamma_{\mathcal{H}}(N) = 2^N for all NN, then its VC-dimension is infinite. Meanwhile,

Remark. You might notice that the VC-dimension of each of these examples happens to equal the number of parameters associated with its hypothesis class. Please note that this does not hold in general.

§ Results: Identifying PAC-Learnability

Now we can finally get back to PAC-learnability! Let's state (without proof) some results using our newfound definitions.

Theorem. (ERM VC Risk Bound) Under the ERM learning algorithm, the following holds with probability at least 1−δ1 - \delta.

R(h^)≤R(h∗)+8⋅log⁡(ΓH(2∣D∣))+log⁡(2/δ)2∣D∣.\mathcal{R}(\hat{h}) \leq \mathcal{R}(h^*) + 8 \cdot \sqrt{ \frac{\log\left(\Gamma_{\mathcal{H}}(2|\mathcal{D}|)\right) + \log(2/\delta)}{2|\mathcal{D}|} }.

It also turns out that the exponent dd in the bound ΓH(N)≤C⋅Nd\Gamma_{\mathcal{H}}(N) \leq C \cdot N^d relates to the VC-dimension!

Theorem. (Sauer-Shelah-Perles) If a hypothesis class H\mathcal{H} has finite VC-dimension d:=VC(H)d := \mathrm{VC}(\mathcal{H}), then for all NN we have:

ΓH(N)≤∑i=0d(Ni).\Gamma_{\mathcal{H}}(N) \leq \sum_{i = 0}^d \binom{N}{i}.

In particular, this implies that ΓH(N)=O(Nd)\Gamma_{\mathcal{H}}(N) = O(N^d), so the degree of polynomial growth of ΓH(N)\Gamma_{\mathcal{H}}(N) is bounded by VC(H)\mathrm{VC}(\mathcal{H}).

Remark. Again, the above theorem is purely set-theoretic. It upper-bounds the size of a collection of subsets Si⊆{1,…,N}S_i \subseteq \{1, \dots, N\} for which no d+1d + 1 elements of {1,…,N}\{1, \dots, N\} are shattered. (The 6.790 notes offer a proof, but I believe it is a fakesolve.)

Putting the previous two theorems together yields the Fundamental Theorem of Statistical Learning.

Theorem. (Fundamental Theorem) A hypothesis class H\mathcal{H} is PAC-learnable if and only if it has finite VC-dimension.

If its VC-dimension d:=VC(H)d := \mathrm{VC}(\mathcal{H}) is finite, then, with probability at least 1−δ1 - \delta, we furthermore have:

R(h^)≤R(h∗)+O(d∣D∣log⁡∣D∣d+1∣D∣log⁡2δ).\mathcal{R}(\hat{h}) \leq \mathcal{R}(h^*) + O\left( \sqrt{\frac{d}{|\mathcal{D}|} \log \frac{|\mathcal{D}|}{d} + \frac{1}{|\mathcal{D}|} \log \frac{2}{\delta}} \right).

Expectedly, the RHS tends to zero as ∣D∣|\mathcal{D}| grows large, confirming PAC-learnability.

Yippee! And so all those hypothesis classes we discussed earlier are now proven PAC-learnable.