Lesson 6.6 · 10 min read · about 55 min to master at a very slow pace
Hard-margin and Soft-margin SVM
The hard-margin optimisation problem, why it fails on overlapping data, slack variables and hinge loss, the soft-margin objective, and how hinge loss compares with logistic and 0–1 loss.
Hard margin
Hard-margin SVM (perfectly separable data)
The constraint says every point is on the correct side and outside the margin. Minimising maximises the width (squaring and halving just make the maths easier).
The problem: real data are rarely separable. One overlapping point makes the constraints impossible, and a single outlier can force a very narrow margin.
Soft margin and hinge loss
Allow violations, but charge for them. For each point define the hinge loss (or slack):
| Where the point is | ||
|---|---|---|
| Correct side, outside the margin | 0 | |
| between 0 and 1 | Correct side, inside the margin | between 0 and 1 |
| Misclassified |
Soft-margin SVM
Equivalently: with . That's hinge loss plus an L2 penalty, the ridge idea applied to classification.
Hinge loss and the objective by hand
: ; ; . , : .
Suppose , and four points have . Then and .
: objective . : objective . A larger makes violations count more, pushing toward a narrower margin with fewer violations.
Hinge vs the other classification losses
Write each loss in terms of the margin (positive = correct):
Because hinge loss is zero for points comfortably on the right side, only margin violators (the support vectors) influence the SVM. Logistic regression is influenced by every point.
Cheatsheet
Hard-margin SVM
Soft-margin SVM
Hinge loss
Check your understanding
Score 75% or more to master this lesson and earn XP. Answer first, then check.