Quiz: maximum margin and support vectors
Before this unit: Linear classifiers (previous unit); Day 33: Random forests.
See also: Day 36: Neural networks; Day 35: Gaussian mixtures.
Short questions to test your understanding. Try each on paper first, then open the answer. The street is -1 \le f(\mathbf x) \le 1, its width 2/\|\mathbf w\|; C is the price of a unit of slack.
Q1. Why is “a line with zero training errors” not a good enough answer, even on separable data?
How many such lines are there, and where do they pass?
There are infinitely many, and some pass just next to training points. A new point that lies a little beyond a training point (noise in its features) would be misclassified. The max-margin line is the one that stays as far as possible from the closest points of both classes; it is also unique.
Q2. You move a training point that is not a support vector, without letting it enter the street. What happens to the SVM? And if you delete it?
Which points fix the street?
Nothing happens in either case: the solution depends only on the support vectors. Moving or deleting a support vector, or moving another point into the street, changes the solution.
Q3. A linear SVM has \mathbf w = (0.6, 0.8) and b = -2. How wide is the street? On which side is the point (1, 1), and is it inside the street?
Compute \|\mathbf w\| and f(1, 1).
\|\mathbf w\| = 1, so the width is 2. f(1, 1) = 0.6 + 0.8 - 2 = -0.6: the -1 side, inside the street (since |f| < 1), at distance 0.6 from the line.
Q4. What happens to the street, the number of support vectors and the sensitivity to a single outlier when you increase C?
C is the price of a violation.
Violations become more expensive: the street gets narrower, fewer points lie inside it (fewer support vectors), and a single outlier can force the line to bend around it. With a small C the street is wide, many points are support vectors, and the line follows the bulk of the data.
Q5. A point has y f = 0.4. Is it classified correctly? What are its 0–1 loss, hinge loss and slack?
Correct means y f > 0; the street’s edge is y f = 1.
Correct (y f > 0), but inside the street. 0–1 loss 0, hinge loss 1 - 0.4 = 0.6, slack 0.6. It is a support vector.
Q6. Why not minimise the number of training errors (the 0–1 loss) directly?
What does the 0–1 loss look like as a function of \mathbf w and b?
It is piecewise constant: moving the line a little either changes nothing or makes the count jump. Its slope is zero or undefined, so a downhill method has no direction; finding its minimum is a hard combinatorial problem. It also ignores how far points are from the line, so it gives no margin. The hinge loss is convex, slopes towards better lines, and is zero only for points outside the street.
Q7. The squared loss (1 - y f)^2 is convex and smooth. Why is it a poor loss for classification?
What does it do to a point with y f = 4?
It punishes points that are far on the correct side (y f = 4 costs 9), so well-classified points pull the line towards themselves; and it grows quadratically for outliers on the wrong side, so one outlier can dominate the total. The hinge is zero for all safe points and grows only linearly for violations.
Q8. (math) Show that the soft-margin objective \tfrac12\|\mathbf w\|^2 + C\sum_i \max(0, 1 - y_i f_i) can be written as “loss + \lambda × regulariser”. What is \lambda?
Divide by C; the minimiser does not change.
Dividing by C > 0: \sum_i \max(0, 1 - y_i f_i) + \frac1C \cdot \tfrac12\|\mathbf w\|^2. So \lambda = 1/C weighs the regulariser \tfrac12\|\mathbf w\|^2 (which prefers wide streets) against the total hinge loss. Large C = small \lambda = weak regularisation.