🧮 Brain Teaser

The SVM Margin Width: Why Does the Distance Equal 2/‖β‖?

You train a hard-margin linear SVM on a linearly separable dataset in Rd\mathbb{R}^d. The decision boundary is {x:xβ+β0=0}\{x : x^\top \beta + \beta_0 = 0\}, with the two class constraints:

yi(xiβ+β0)1,i.y_i(x_i^\top \beta + \beta_0) \geq 1, \quad \forall i.

Question: Support vectors of the positive class satisfy xβ+β0=+1x^\top \beta + \beta_0 = +1, and support vectors of the negative class satisfy xβ+β0=1x^\top \beta + \beta_0 = -1.

(a) Show that the geometric margin (Euclidean distance between the two parallel hyperplanes xβ+β0=+1x^\top\beta + \beta_0 = +1 and xβ+β0=1x^\top\beta + \beta_0 = -1) equals 2β\dfrac{2}{\|\beta\|}.

(b) Hence, explain intuitively why maximizing the margin is equivalent to minimizing β2\|\beta\|^2, and why this turns into the clean convex problem:

minβ,β012β2subject to yi(xiβ+β0)1,  i.\min_{\beta,\beta_0} \frac{1}{2}\|\beta\|^2 \quad \text{subject to } y_i(x_i^\top\beta + \beta_0) \geq 1, \; \forall i.

(c) Surprise twist: If you rescale β2β\beta \mapsto 2\beta and β02β0\beta_0 \mapsto 2\beta_0 (keeping the same decision boundary), what happens to the margin? And what happens to the constraint values yi(xiβ+β0)1y_i(x_i^\top \beta + \beta_0) \geq 1? What does this tell you about the role of the normalization f(xsv)=1\|f(x_{\text{sv}})\| = 1?

SVMmarginconvex optimizationgeometric intuitionnormalization

Answer: SVM Margin Width: Why 2/‖β‖?

Key Idea / Intuition

The SVM margin is just a Euclidean distance between two parallel hyperplanes. The key insight is that the functional margin (the value of xβ+β0x^\top\beta + \beta_0) is not scale-invariant — you can always rescale β\beta to make the constraints say anything you want. The SVM "pins" this freedom by canonically requiring that support vectors lie exactly on the ±1\pm 1 level sets, which makes the geometric distance calculable as 2/β2/\|\beta\|. Maximizing this distance is then equivalent to minimizing β\|\beta\|, giving a clean quadratic program.


Formal Proof / Solution

Part (a): The Margin Width

The two margin hyperplanes are: H+:xβ+β0=+1,H:xβ+β0=1.H_+ : x^\top\beta + \beta_0 = +1, \qquad H_- : x^\top\beta + \beta_0 = -1.

Take any point x+x_+ on H+H_+ and project it onto HH_-. The unit normal to both hyperplanes is n^=β/β\hat{n} = \beta / \|\beta\|.

The signed distance from a point xx to the hyperplane xβ+β0=cx^\top\beta + \beta_0 = c is:

dist(x,H)=xβ+β0cβ.\text{dist}(x, H) = \frac{x^\top\beta + \beta_0 - c}{\|\beta\|}.

So the distance from H+H_+ to HH_- is:

margin=(+1)(1)β=2β.\text{margin} = \frac{(+1) - (-1)}{\|\beta\|} = \frac{2}{\|\beta\|}.

This can also be seen concretely: if x+x_+ is a support vector on H+H_+, then moving in the n^-\hat{n} direction by distance dd gives a point x+dn^x_+ - d\hat{n} on HH_-:

(x+dββ)β+β0=1dβ=1    d=2β.\left(x_+ - d\frac{\beta}{\|\beta\|}\right)^\top \beta + \beta_0 = 1 - d\|\beta\| = -1 \implies d = \frac{2}{\|\beta\|}.

margin=2β.\boxed{\text{margin} = \frac{2}{\|\beta\|}.}


Part (b): Maximizing Margin ↔ Minimizing β2\|\beta\|^2

Maximizing the margin 2/β2/\|\beta\| over β\beta (subject to correct classification with functional margin 1\geq 1) is equivalent to:

maxβ2β    minββ    minβ12β2.\max_\beta \frac{2}{\|\beta\|} \iff \min_\beta \|\beta\| \iff \min_\beta \frac{1}{2}\|\beta\|^2.

The factor 12\frac{1}{2} is a convenient constant for calculus (it kills the 22 when differentiating), and the square is used because it's strictly convex and smooth, making the optimization problem a standard quadratic program with linear constraints:

minβ,β012β2s.t.yi(xiβ+β0)1,  i.\min_{\beta, \beta_0} \frac{1}{2}\|\beta\|^2 \quad \text{s.t.} \quad y_i(x_i^\top\beta + \beta_0) \geq 1,\; \forall i.

This is convex, has a unique global minimum, and can be solved efficiently via Lagrange duality.


Part (c): The Surprise — Rescaling

If we replace β2β\beta \mapsto 2\beta, β02β0\beta_0 \mapsto 2\beta_0:

  • The decision boundary {x:xβ+β0=0}\{x : x^\top\beta + \beta_0 = 0\} is unchanged (just multiply through by 2).
  • The geometric margin becomes 22β=1β\dfrac{2}{\|2\beta\|} = \dfrac{1}{\|\beta\|}it halves!
  • The constraint values become yi(xi(2β)+2β0)=2yi(xiβ+β0)2y_i(x_i^\top(2\beta) + 2\beta_0) = 2 \cdot y_i(x_i^\top\beta + \beta_0) \geq 2 — the constraints are now more than satisfied.

The punchline: The constraint yi(xiβ+β0)1y_i(x_i^\top\beta + \beta_0) \geq 1 is a canonical normalization that removes the scale ambiguity. Without it, you could inflate β\beta arbitrarily while maintaining the same geometry. The constraint anchors the scale so that the functional margin of support vectors equals exactly 11, making β\|\beta\| a meaningful proxy for the inverse margin. This is sometimes called choosing the canonical separating hyperplane.

In other words: the SVM doesn't just find a separating hyperplane — it finds the unique representative in each equivalence class of rescaled hyperplanes, chosen so that the closest point has functional value exactly ±1\pm 1.

Source: The Elements of Statistical Learning, Hastie, Tibshirani & Friedman, 2nd ed., Section 12.2

Type: ML/StatsSource: The Elements of Statistical Learning, Hastie, Tibshirani & Friedman, 2nd ed., Section 12.2Edit on GitHub ↗