Concepts / Shattering

Shattering

The two matching bounds give VCdim(H) = 2 for the class H of intervals over the real numbers.

  • Programming
Interactive lab

Try it: Shattering and VC Dimension

What it means for a hypothesis class to shatter a set of points: all labelings are checked exactly, each realizable one with a witness hypothesis drawn, until the first labeling no hypothesis can produce — linked to the VC dimensions of thresholds (1), intervals (2), halfspaces in the plane (3) and axis-aligned rectangles (4).

How it works

  1. Pick a hypothesis class and place n points.
  2. Enumerate all labelings of the points with 0 / 1.
  3. For each labeling decide exactly whether some hypothesis produces it (thresholds: every 1 left of every 0; intervals: no 0 between the outer 1s; rectangles: no 0 in the bounding box of the 1s; halfspaces: strict linear separability).
  4. Draw a witness hypothesis for every realizable labeling.
  5. The set is shattered if every labeling is realized; VCdim is the size of the largest shattered set.

Default run (6 steps): 2 points and the class of intervals on a line (VC dimension 2). Check all 2^2 = 4 labelings: is each one produced by some hypothesis? … All 4 labelings are realized: intervals on a line shatter these 2 points, so VCdim >= 2. Theory: VCdim = 2, so no set of 3 points can be shattered.

Simplified: At most 6 points on a 0–10 board. The lab checks one placement at a time: failing to shatter one set of n points does not by itself show VCdim < n — that needs every placement (the lab states the known VC dimension).

Educational simulation

Loading the simulation…

A Labeling Challenge

Imagine placing a finite collection of points on the real number line. An interval chooses some of those points and leaves the others unchosen. We can record this choice with binary labels: a point inside the interval receives 1, and a point outside the interval receives 0. The central question is how many different labelings an interval class can produce on the same fixed set of points.

What do you think happens?

Can one class of intervals produce every possible binary labeling of two ordered points?

  • Yes

  • No

Reveal answer
Answer:

Yes

Intervals can select neither point, either one of the two points, or both points. Therefore they realize all four labelings of a two-point set.

Intervals as Binary Functions

Definition

The class of intervals over the real numbers is a class of binary-valued functions. An interval is determined by endpoints a and b with a less than b. For a chosen interval, each real number receives the value 1 if it lies inside the interval and the value 0 if it lies outside it.

The interval therefore acts as a rule for labeling points. It does not assign arbitrary labels independently to each point. Instead, the labels are controlled by membership in one connected region of the real line: points selected by the interval receive 1, while points not selected receive 0.

Selected intervalmembership rulePoint inside1Point outside0containsdoes not contain
Which real numbers receive value 1 or 0 from a selected interval?

Meaning of Shattering

Definition

A function class shatters a finite set when it achieves every possible labeling of that set. For a set of n points, every assignment of binary values to those points must be produced by some function in the class.

For two points, the possible labelings are 0, 0; 0, 1; 1, 0; and 1, 1. To prove that intervals shatter the two-point set, we must show that each of these four patterns can be produced by choosing a suitable interval. It is not enough to produce several patterns; shattering requires every possible pattern.

Fixed set Ctwo points00neither selected01second selected10first selected11both selectedchoose an intervalchoose an intervalchoose an intervalchoose an interval
What does it mean for an interval class to realize every binary labeling of one fixed set?

Two Points Can Be Shattered

Worked example

The set containing 1 and 2

Show that intervals realize every labeling of the set C = {1, 2}.

  1. 1
    Labeling 0, 0

    Choose an interval that contains neither 1 nor 2.

  2. 2
    Labeling 1, 0

    Choose an interval around 1 that does not contain 2.

  3. 3
    Labeling 0, 1

    Choose an interval around 2 that does not contain 1.

  4. 4
    Labeling 1, 1

    Choose an interval wide enough to contain both 1 and 2.

Result

All four labelings are realized, so the interval class shatters C = {1, 2}.

Label of 1Label of 2What the interval must do
00Exclude both points
10Include 1 and exclude 2
01Exclude 1 and include 2
11Include both points

The four possible binary labelings of the two-point set {1, 2}.

00neither point insideInterval Arealizes 0010first point insideInterval Brealizes 1001second point insideInterval Crealizes 0111both points insideInterval Drealizes 11producesproducesproducesproduces
How can intervals on the real line realize all four possible positive and negative labelings of two ordered points?

The Three-Point Obstacle

Now consider any three points and arrange them from left to right as c1, c2, and c3, with c1 less than or equal to c2 and c2 less than or equal to c3. One possible labeling is 1, 0, 1: the two outer points should be inside the interval, while the middle point should be outside.

This labeling cannot be produced by an interval. If an interval reaches c1 and c3, then it must also include the point c2 lying between them. The interval cannot include both outer points while leaving the middle point outside.

c11c11c20c21c31c31interval reaches c1middle point is betweeninterval reaches c3
Why can no single interval label the two outer points positive while labeling the middle point negative?

From Shattering to VC-Dimension

Definition

The VC-dimension of a function class is the size of the largest set shattered by that class. It measures how many different labelings the class can produce on a finite set at its largest completely flexible size.

For intervals, the lower bound comes from the two-point set {1, 2}, which is shattered. Therefore the VC-dimension is at least 2. The upper bound comes from the three-point argument: no set of three points can be shattered because the labeling 1, 0, 1 is impossible. Therefore the VC-dimension cannot be 3 or larger.

Two pointsshatteredVC-dimension 2largest shattered sizeThree pointsnot shatteredat least 2less than 3
How does a shattered set of two points and an unshatterable set of three points determine the VC-dimension?
Key point

The two matching bounds give VCdim(H) = 2 for the class H of intervals over the real numbers.

Common Reasoning Mistakes

  • Common mistake

    Showing only some labelings of two points

    What it looks like

    Producing 0, 0 and 1, 1, then concluding that the set is shattered

    Why it fails

    Shattering requires every possible labeling, including 1, 0 and 0, 1.

    Do this instead

    List all four labelings of two points and account for each one.

  • Common mistake

    Treating the labels of three points as independent choices

    What it looks like

    Assuming an interval can always produce 1, 0, 1 because each point is assigned a binary value

    Why it fails

    The labels must come from one interval, and an interval that contains both outer points must contain the point between them.

    Do this instead

    Use the order of the points on the real line when checking whether a labeling is possible.

  • Common mistake

    Proving only that one particular three-point set is not shattered

    What it looks like

    Using three selected numbers and stopping after showing that their 1, 0, 1 labeling fails

    Why it fails

    To establish the upper bound, the argument must apply to any three-point set.

    Do this instead

    Write the points generally as c1, c2, and c3 in sorted order, then apply the middle-point argument.

  • Common mistake

    Confusing a lower bound with the final VC-dimension

    What it looks like

    Finding a shattered set of two points and immediately declaring the VC-dimension to be 2

    Why it fails

    A shattered two-point set proves only that the VC-dimension is at least 2.

    Do this instead

    Also show that no three-point set is shattered, giving the matching upper bound.

Check Your Understanding

EASY

Let C be a set of three ordered real points c1, c2, and c3. Explain why the labeling 1, 0, 1 cannot be produced by any interval. Then state what this implies about shattering three-point sets.

Hints
  • Identify which points the interval must contain.
  • Use the fact that c2 lies between c1 and c3.
  • Connect the failed labeling to the definition of shattering.
MEDIUM

For the set C = {1, 2}, describe what an interval must do to produce each of the four labelings: 0, 0; 0, 1; 1, 0; and 1, 1. Use your list to justify that intervals shatter C.

Hints
  • Interpret 1 as inside the interval.
  • Interpret 0 as outside the interval.
  • There are four possible binary labelings of two points.

Final Takeaways

  1. 1
    Intervals over the real numbers form a class of binary-valued functions: points inside an interval receive 1, and points outside receive 0.
  2. 2
    A class shatters a finite set when it realizes every possible binary labeling of that set.
  3. 3
    Intervals shatter the two-point set {1, 2} because they can realize all four labelings.
  4. 4
    No interval can realize the labeling 1, 0, 1 on three ordered points because the middle point lies between the two outer points.
  5. 5
    The largest shattered set has size 2, so the VC-dimension of intervals over the real numbers is 2.

At a glance

  • Shattering means realizing every possible labeling of a fixed finite set.
  • An interval labels points according to membership: inside means 1 and outside means 0.
  • Intervals shatter two points but cannot shatter three points.
  • The impossible three-point labeling is 1, 0, 1.
  • The VC-dimension of the class of intervals over the real numbers is 2.

Related concepts

More concepts starting with S