VC Dimension
Source: Unit 5 §11
Why VC dimension?
The finite- bound has two drawbacks:
- The bound can be very loose, and therefore weak, for large .
- It does not work at all when is infinite.
When is infinite? Infinitely many lines can separate two real-valued points, so is infinite. For infinite the sample-complexity bound fails, and VC dimension comes to the rescue.
Shattering
A dichotomy of a set is a partition of into two disjoint subsets - in other words, a labelling. A set of points has possible dichotomies.
SHATTERS if every possible dichotomy of can be represented by some hypothesis in - that is, is consistent with every labelling of .
With 2 points and a line as the model there are labellings; if can realize all 4, then shatters those 2 points.
Definition of VC dimension
If can shatter arbitrarily large finite subsets, then .
For finite :
- Suppose .
- To shatter instances, needs distinct hypotheses, one per labelling.
- So .
- Taking logs, .
Worked examples
1. Intervals on the real line
and H = { a < x < b }. The answer is VC(H) = 2.
- Take
S = {1.5, 2.7}. There are labellings to realise. - Cover both:
1 < x < 4. ✓ - Cover neither:
0 < x < 1. ✓ - Cover 1.5 only:
1 < x < 2. ✓ - Cover 2.7 only:
2 < x < 4. ✓ So two points are shatterable. - Now take
S = {x, y, z}with . To cover{x, z}but not is impossible: any interval containing and must also contain . ✗ - The largest shatterable set has size 2, so VC(H) = 2.
2. Linear decision surfaces (the perceptron)
and is the set of all lines. A line can shatter any 3 non-collinear points, realising all labellings, but it cannot shatter 4 points - an XOR-like layout defeats it. Therefore VC(H) = 3.
That is the perceptron with inputs.
3. Conjunction of up to 3 boolean literals
Take S = {x₁ = 100, x₂ = 010, x₃ = 001}. To realise a given dichotomy, add the
literal for every you want to exclude. For example, to
include while excluding and , use
. This set of 3 is shatterable, so VC(H) = n - here
3 - for conjunctions of up to literals.
The source sentence reads "to realize a dichotomy including , add literal ", which contradicts the example printed immediately after it. Its own example is the correct one, and it is the version used above: excludes . Verify it on the numbers - demands bit 1 = 0 and bit 3 = 0, so it rejects and and accepts , which is exactly the dichotomy that was wanted.
4. The sine wave
For , VC = ∞ with only 2 parameters. By choosing the phase and period carefully it can shatter almost any set of one-dimensional points.
The sine wave has two parameters and infinite VC dimension. VC dimension measures the true power or capacity of a model class, not how many knobs it exposes.
VC dimension, model complexity and generalization
- VC dimension does not depend on the training set. It is a property of the model class.
- A model class that can learn any labelling of random points is too powerful and will overfit. VC dimension is the maximum it can shatter for all labellings.
The generalization bound, from the alternate VC deck:
| Symbol | Meaning |
|---|---|
n | size of the training set |
h | model complexity, i.e. the VC dimension |
p | the probability that the bound fails |
Choose the model complexity that minimises the bound. In practice the bound is often loose, so treat the theory as insight, not as a magic recipe for model selection.
- If is very big relative to , a low training error probably means you got lucky - that is overfitting.
- If is sufficiently constrained, or is large, then a low training error is good evidence of low generalization error.
For infinite there is an alternative bound on expressed in terms of VC(H) instead of : the VC dimension simply replaces the size of the hypothesis space in the sample-complexity formula.