Defining VC dimension and 2D linear classifier capacity
VC dimension is the largest number of points for which a hypothesis class can realize every possible labeling (shatter). For 2D linear classifiers, the VC dimension is 3 because any set of 3 points in general position can be separated in all labelings by some line, but no set of 4 points—including the XOR pattern of four points at square corners with alternating labels—can be shattered. This finite VC dimension controls generalization: it bounds how close empirical error is to true error as sample size grows, with smaller VC dimension implying better generalization and lower sample complexity.
One of the standard combinatorial ways of talking about the “size’’ of a hypothesis class (\mathcal{H}) is via shattering. Given a finite set of points (S={x_1,\dots,x_n}), consider all (2^n) possible assignments of binary labels to those points. We say that (\mathcal{H}) shatters (S) if for every one of those (2^n) labelings there is some (h\in\mathcal{H}) that realizes it, i.e. (h(x_i)=y_i) for all (i). The VC dimension (\mathrm{VC}(\mathcal{H})) is defined as
[
\mathrm{VC}(\mathcal{H}) ;=; \sup{,n:\text{there exists a set of }n\text{ points shattered by }\mathcal{H},}.
]
If no finite (n) works, the VC dimension is said to be infinite.
For halfspaces in (\mathbb{R}^2) – classifiers of the form (h_{w,b}(x)=\operatorname{sign}(w^\top x + b)) – you can check that any three points in general position can be labeled arbitrarily with a line: with one point above the line, two below, all three above, etc., you can always draw a line to implement the labeling as long as the three points are not collinear. On the other hand, there exist sets of four points and labelings that are not realizable. The classic example is the XOR labeling of the four corners of a square:
[
(0,0)\mapsto -, \quad (1,0)\mapsto +, \quad (0,1)\mapsto +,\quad (1,1)\mapsto -.
]
No single straight line separates the “+’’ corners from the “–’’ corners in this configuration, so this set of four points is not shattered. More generally, it can be shown that although some labelings of four points are achievable, there is no configuration of four points in (\mathbb{R}^2) for which all (2^4) dichotomies are achievable by lines. That pins down (\mathrm{VC}()2D linear classifiers()) at 3.
The VC dimension enters generalization theory via uniform convergence bounds. A typical result says that for any (\delta\in(0,1)), with probability at least (1-\delta) over an i.i.d. sample of size (m),
[
\sup_{h\in\mathcal{H}} \bigl|\text{true_error}(h)-\text{empirical_error}(h)\bigr| ;\leq; O!\left(\sqrt{\frac{\mathrm{VC}(\mathcal{H})\log(m)+\log(1/\delta)}{m}}\right).
]
Equivalently, to guarantee that the empirical error is within (\varepsilon) of the true error for all (h\in\mathcal{H}), one needs on the order of ((\mathrm{VC}(\mathcal{H})+\log(1/\delta))/\varepsilon^2) samples. Thus the finite capacity of lines in (\mathbb{R}^2) (VC dimension 3) means they cannot fit arbitrary labelings such as XOR, and the same finiteness controls how many samples are needed to expect good generalization.