4.5 VC-dimension
In this section we discuss a measure of the complexity of a hypothesis set \(\mathcal H\), the Vapnik–Chervonenkis (VC) dimension.
We call one possible way of labeling a set of points, \(S\), a dichotomy and we say that \(S\) is shattered by \(\mathcal H\) when \(\mathcal H\) can generate all possible dichotomies of \(S\). The VC-dimension of \(\mathcal H\) is the size of the largest set that can be shattered by \(\mathcal H\).
First consider the example of the real line and \(\mathcal H\) being the classifiers that classify to one class to the left of a point and to the other class to the right of the point. If \(S\) consists of two points, all four dichotomies can be realized and so \(S\) can be shattered by \(\mathcal H\). However if \(S\) consists of three points, the dichotomy (1,0,1) cannot be realized and \(S\) cannot be shattered. Therefore the VC-dimension of \(\mathcal H\) is \(d_{VC}=2\).
Figure 4.9: Two points can be shattered
Figure 4.10: Three points that can not be shattered
Next consider points on \(\mathbb R^2\) and \(\mathcal H\) being the set of straight lines, as in the example in the previous section. Clearly three points can be shattered by a straight line, as long as the points are not colinear. However four points can never be shattered. So the VC-dimension is \(d_{VC}=3\). Similarly in \(R^p\), if \(\mathcal H\) are the hyperplanes, \(d_{VC} = p+1\).
Figure 4.11: Three points can be shattered but not four
We see a pattern here, the VC-dimension is equal to the number of parameters of \(\mathcal H\). This is however not always true. As a counterexample, take the functions \(\left\{ x\mapsto sin(\omega x)\mid \omega\in \mathbb R \right\}\). Then label a point \(x\) according to the sign of \(sin(\omega x)\). There is only one parameter, but any \(S\) can be shattered and so \(d_{VC}=\infty\).
Figure 4.12: A one parameter function can shatter any number of points
The important quantity here is \(n/d_{VC}\). If the sample size \(n\) is large in relation to the VC-dimension \(d_{VC}\), the out-of-sample error is guaranteed to be close to the in-sample error. The bound is loose, so the actual value is not useful in practice. Rather it provides a way of thinking about generalization from in-sample to out-of-sample error. In practice, it is usually the case that models with lower \(d_{VC}\) generalizes better than models with higher \(d_{VC}\). A popular rule of thumb is that \(n\) should be at least \(10\times d_{VC}\). However, there are also algorithms with \(d_{VC}=\infty\) that work well in practice.
A different way of thinking of this results is \[ E_{out}(h) = E_{in}(h) + \Omega(n,\mathcal H, \delta), \] where \(\Omega\) is a penalty for model complexity. As we choose a more complex \(\mathcal H\) (with higher \(d_{VC}\)) the in-sample error will become smaller. But, at the same time the penalty \(\Omega\) gets larger. The penalty gets smaller when we have more samples. The optimal model, with smallest \(E_{out}\), is therefore a compromise that minimize the sum of the two terms.
One commonly used way to estimate \(E_{out}\) is to split the data into one training set and one test set. The test set is not used for training and so when we calculate \(E_{test}\), we do this for only one \(h\), the one with minimal in-sample error. Therefore Hoeffding’s inequality applies as a generalization bound, which is much tighter than the VC-bound.
In the figure below we visualize the partition of the out-of-sample error into in-sample error and generalization error.
Figure 4.13: Sketch of the different components of the error