SVM Margin
Width of the separating margin an SVM maximizes between classes.
Formula
Variables
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
More in Machine Learning & AI
View allLinear Regression Model
BasicPredicts a continuous value as a weighted sum of input features plus a bias.
Gradient Descent Update
BasicIteratively moves parameters in the direction that most reduces the loss.
ReLU Activation
BasicRectified Linear Unit: outputs the input if positive, else zero.
Leaky ReLU
BasicA ReLU variant that lets a small gradient flow for negative inputs.
Tanh Activation
BasicSquashes input to the range (-1, 1); zero-centred activation.
Softmax
BasicTurns a vector of scores into a probability distribution that sums to 1.