Lagrange multipliers turn the margin problem into its dual: maximise Σαᵢ − ½ΣΣ αᵢαⱼyᵢyⱼ xᵢ·xⱼ with αᵢ ≥ 0 and Σαᵢyᵢ = 0. The solution is w = Σαᵢyᵢxᵢ, complementary slackness makes αᵢ non-zero only for support vectors, and because the data enters only through dot products, any kernel can replace them.
Machine Learning Techniques
The maximum-margin problem has a hidden second form, its dual, and the dual is where the SVM's best properties come from: it shows that the solution depends only on the support vectors, and that the data enters only through dot products, so kernels apply. Getting there takes one idea from optimisation, Lagrange multipliers for inequality constraints.
Constrained optimisation in brief
Take the general problem
wminf(w)subject togi(w)≤0,i=1,…,n.
Attach a multiplierαi≥0 to each constraint and form the Lagrangian
L(w,α)=f(w)+i∑αigi(w).
Here is the key observation. For a fixed w, maximise the Lagrangian over α≥0. If w breaks some constraint (gi(w)>0), raising αi makes the Lagrangian infinite. If w satisfies every constraint, every gi(w)≤0, so the best choice is to make each term zero, and the maximum is just f(w). So
wminα≥0maxL(w,α)
is exactly the original constrained problem: the inner maximum acts as an infinite penalty on infeasible w.
The dual problem swaps the order:
α≥0maxwminL(w,α).
In general the dual's optimum is at most the original (primal) optimum. For convex problems such as the SVM, under a mild condition that holds whenever the data is separable, the two are equal (strong duality), so we may solve whichever form is more convenient.
The SVM dual
For the hard-margin SVM, f(w)=21∥w∥2 and the constraints are 1−yi(w⊤xi+b)≤0. The Lagrangian is
L(w,b,α)=21∥w∥2+i=1∑nαi(1−yi(w⊤xi+b)).
Minimise over w and b by setting the derivatives to zero:
This is again a convex quadratic program, now in n variables (one per training point) instead of d+1.
What the dual reveals
1. The weights are a combination of training points
w=∑iαiyixi. Once more, the solution lives in the span of the data, just as in kernel PCA and kernel regression.
2. Only support vectors count
At the optimum, the complementary slackness condition holds for every point:
αi(1−yi(w⊤xi+b))=0.
Either αi=0, or the constraint is tight, yi(w⊤xi+b)=1, meaning the point lies exactly on the edge of the street. So αi>0 only for support vectors; every other point has αi=0 and drops out of w=∑iαiyixi. This is the precise form of the statement in the last chapter: the classifier is built from the support vectors alone. The intercept follows from any support vector s: b=ys−w⊤xs.
3. The data appears only through dot products
Look at the dual objective: the training points enter only as xi⊤xj. And a prediction for a new point is
f(x)=w⊤x+b=i∈SV∑αiyixi⊤x+b,
again only dot products, and only with the support vectors.
Kernel SVMs
So the kernel trick applies exactly as in Module 3. Replace every dot product by a kernel, xi⊤xj→k(xi,xj):
This finds the maximum-margin hyperplane in the kernel's feature space without ever computing the feature vectors. With a polynomial kernel the boundary in the original space is a polynomial curve; with the RBF kernel it can wrap around clusters of any shape, such as one ring inside another.
The kernel SVM also solves the cost problem of kernel regression. Kernel regression's prediction needed a kernel value with every training point; the SVM's needs only the support vectors, often a small fraction of the data.
A linear SVM cannot separate rings (left); the same algorithm with an RBF kernel draws a closed boundary between them (right). Only the circled support vectors define it.
The RBF kernel k(x,x′)=exp(−γ∥x−x′∥2) (here written with γ=1/2σ2) has a width parameter that matters a great deal. Small γ (wide kernel): each support vector influences a large region, and the boundary is smooth, approaching a linear one. Large γ (narrow kernel): influence is very local, the boundary can wrap around individual points, and the model overfits, with almost every point becoming a support vector. γ and the soft-margin parameter C (next chapter) are chosen together by cross-validation.
MediumSVMDuality
Using complementary slackness, explain why a point that lies strictly outside the margin has αᵢ = 0.
MediumSVMKernels
Why does the dual formulation, rather than the primal, make kernels possible?
MediumSVMComplexity
A trained RBF SVM has 40 support vectors out of 10,000 training points. What does prediction cost, and what does a much larger count suggest?