What is the VC dimension of axis-aligned rectangles in R2, and how do you prove it?

Learning theory, VC dimension
Level L3 Intermediate. Length Medium. Nature Th+Mat Both.

What's being asked

Whether you can construct a shattered configuration and find an argument that rules out every set of five points.

Key idea

A "diamond" of 4 points can be shattered, and among any 5 points the extreme points (leftmost, rightmost, lowest, highest) force the remaining point inside their bounding box. So VCdim⁡=4.

Steps

  1. Lower bound: take N=(0,1), S=(0,−1), E=(1,0), W=(−1,0). For each subset, the smallest rectangle containing it must contain no other chosen point.
  2. Check subsets: a single point gets a tiny rectangle. {N,S} gets a thin rectangle around x=0, which misses E and W since they are at x=±1. {N,E} gets [0,1]×[0,1], which contains neither S nor W. Three points such as {N,E,S} get [0,1]×[−1,1], which excludes W. All four get the big square. The empty set gets a rectangle elsewhere. So all 16 labellings occur and VCdim⁡≥4.
  3. Upper bound: take any 5 points. Choose up to 4 of them as extreme: one with the smallest x, one with the largest x, one with the smallest y and one with the largest y (ties broken arbitrarily).
  4. At least one of the 5 points is not chosen. It lies inside the bounding box of the chosen points.
  5. Consider the labelling with all chosen points positive and this extra point negative. Any rectangle containing the chosen points contains their bounding box, hence the extra point. So the labelling is impossible, no 5 points are shattered, and VCdim⁡=4.

Common mistakes

How long your answer should be

Half a page; 4–5 minutes.

Last checked on 4 December 2026.

Read this

Previous in Learning theory: In AdaBoost each weak learner has weighted error ϵt=0.4. Using the bound exp⁡(−2γ2T) on training error, how many rounds T guarantee training error below 1%? How does the exact product of the Zt compare with the bound?
Next in Learning theory: How do you prove the perceptron convergence theorem (Novikoff): if ∥xi∥≤R and some unit vector w∗ has yi w∗ ⁣⋅xi≥γ>0 for all i, then the perceptron makes at most R2/γ2 mistakes?