On separable data the perceptron stops at the first boundary that works, and different runs stop at different boundaries. Some of them skim past training points; others sit comfortably in the middle of the gap. Intuitively the middle is safer: a new point that is slightly different from the training points is less likely to land on the wrong side. The perceptron's own mistake bound, , said the same thing in mathematics: a wide margin makes a problem easy. The support vector machine (SVM) turns the intuition into an objective.
The margin of a hyperplane
Take a hyperplane (now with an explicit intercept ). The distance from a point to it is
If the hyperplane classifies correctly, , so the distance can be written without the absolute value as . The margin of the hyperplane is its distance to the closest training point. We want the separating hyperplane whose margin is largest:
Fixing the scale
The pair and any rescaled pair with describe the same hyperplane, so we are free to choose a scale. Choose it so that the closest points satisfy
and every point satisfies . With this choice the closest points are at distance , and the empty "street" between the two classes, bounded by the parallel hyperplanes , has width
Maximising is the same as minimising , or, more conveniently, . The problem becomes
This is the hard-margin SVM. The objective is a convex quadratic (a bowl) and the constraints are linear, so it is a convex quadratic program: it has a single global optimum, which standard solvers find reliably. Unlike the perceptron, the answer does not depend on the order of the data or the starting point.
Support vectors
At the optimum, most constraints are slack: most points sit strictly outside the street, with . Only the points exactly on the street's edges have their constraints active. These are the support vectors. They alone determine the solution: delete any other point (or move it anywhere outside the street) and the optimal hyperplane does not change, while moving a support vector moves the hyperplane.
This is the SVM's version of compression. A data set of a million points may have only a few hundred support vectors, and the classifier is completely described by them. The next chapter makes this precise through the dual problem, which also opens the door to kernels.
Why a wide margin generalises
There are several ways to see why maximising the margin helps on new data.
- Robustness. Each training point could be moved by up to the margin in any direction without being misclassified. If new points are noisy copies of training points, a wide margin absorbs the noise.
- Few mistakes are possible. The perceptron bound shows that a large margin relative to the data's size means a simple problem.
- Capacity control. Learning theory shows that the set of classifiers with margin at least on data of radius is effectively limited by , regardless of the number of features. That is why SVMs can work in very high (even infinite) dimensional feature spaces without overfitting, provided the margin is wide.
The hard-margin SVM has one fatal flaw: if the data is not separable, the constraints cannot all be satisfied and the problem has no solution. A single mislabelled point can do that. The soft margin, two chapters on, fixes it.