Machine Learning & AI
Intermediate

SVM Margin

Width of the separating margin an SVM maximizes between classes.

Formula

M=2∥w∥M = \dfrac{2}{\lVert \mathbf{w}\rVert}

Variables

\mathbf{w}Weight vector

Example

Smaller ||w|| means a wider margin

How it works

In a linear support vector machine, the decision boundary is the hyperplane \(\mathbf{w}^T\mathbf{x}+b=0\), and the two closest class boundaries are usually written as \(\mathbf{w}^T\mathbf{x}+b=\pm 1\). The distance between these two parallel hyperplanes is \(2/\|\mathbf{w}\|\), so the formula tells you how wide the separation region is in the data space. This works because the vector \(\mathbf{w}\) sets the orientation of the boundary, and its norm controls how quickly the decision function changes with movement perpendicular to the hyperplane: a smaller norm means the score changes more slowly, spreading the two margin planes farther apart.

When to use it

Use this when analyzing or explaining a linear SVM, especially if you want to understand how model parameters relate to robustness and class separation. It is also useful when comparing SVM solutions or discussing why regularization, which tends to shrink \(\|\mathbf{w}\|\), can increase margin width.

Worked example, step by step

Suppose a trained linear SVM has weight vector \(\mathbf{w} = (3, 4)\). Step 1: Compute the norm of \(\mathbf{w}\): \(\|\mathbf{w}\| = \sqrt{3^2 + 4^2} = \sqrt{9+16} = \sqrt{25} = 5\) Step 2: Plug into the margin formula: \(M = \dfrac{2}{\|\mathbf{w}\|} = \dfrac{2}{5}\) Step 3: Convert to decimal: \(M = 0.4\) Final answer: the SVM margin width is \(0.4\) units.

Common mistakes to avoid

  • Using the length of \(\mathbf{w}\) directly instead of taking \(2/\|\mathbf{w}\|\)
  • Forgetting that the margin formula applies to the geometric width between the two margin hyperplanes, not the distance from one class to the decision boundary
  • Confusing the weight vector \(\mathbf{w}\) with the bias term \(b\), which shifts the hyperplane but does not affect the margin width

Did You Know?

SVMs find the single hyperplane that maximizes the gap to the nearest points of each class.

Share this formula

Reviewed & maintained by the FormulaWon editorial teamLast reviewed September 2026