ContentsChapter 6 · Kernels and SVMs2 of 3

6.2

Soft margin and the dual

In this chapter
  1. 6.1Maximum margin
  2. 6.2Soft margin and the dual
  3. 6.3The kernel trick
Before you readOne unusual point forces a narrow margin. What if you let it step inside the strip?
Watch: Learning: Support Vector Machines · MIT OpenCourseWare · Watch the derivation for the dual; it starts from a hard margin.

The soft-margin SVM charges for crossing a margin edge rather than forbidding it. Write mi=yif(xi)m_i=y_i f(x_i) for a point’s score signed by its true label. Its penalty, the hinge loss, is max⁡(0,1−mi)\max(0,1-m_i)

0123-1012
Hinge loss = 0.50
Move the signed score (horizontal axis). At m≥1m\ge1 there is no loss. For 0<m<10<m<1 the prediction is right but inside the margin. At m=0m=0 it is on the boundary; below 00 it is wrong.

The SVM minimises

12∥w∥2+C∑imax⁡(0,1−mi).\tfrac12\|w\|^2 + C\sum_i\max(0,1-m_i).

The first term favours a wide margin; the second charges for violations. With larger CC violations cost more. With smaller CC the model is more willing to let points enter the strip or even land on the wrong side. Equivalently, give each point slack ξi≥0\xi_i\ge0 require mi≥1−ξim_i\ge1-\xi_i and charge CξiC\xi_i The cheapest slack is exactly the hinge loss.

The dual

Instead of solving directly for ww solve for one weight αi\alpha_i per training point. Maximise

∑iαi−12∑i,jαiαjyiyj(xiTxj)\sum_i\alpha_i - \tfrac12\sum_{i,j}\alpha_i\alpha_j y_i y_j (x_i^Tx_j)

subject to 0≤αi≤C0\le\alpha_i\le C and ∑iαiyi=0\sum_i\alpha_i y_i=0 The resulting direction is w=∑iαiyixiw=\sum_i\alpha_i y_i x_i so the prediction score is

f(x)=∑iαiyi(xiTx)+b.f(x)=\sum_i\alpha_i y_i (x_i^T x)+b.

Only points with αi>0\alpha_i>0 contribute; these are the support vectors. Both formulas use the input vectors only in dot products. That is what lets the next section change the features without writing them all out.

Recall
What changes when CC increases in the soft-margin objective?
Recall
Which training points contribute to the dual prediction score?
Exercise
Three points have signed scores 1.21.2 0.40.4 and −0.5-0.5 What is their total hinge loss before multiplying by CC
Exercise
Two support vectors have labels +1,−1+1,-1 weights α1=α2=0.5\alpha_1=\alpha_2=0.5 and dot products x1Tx=3x_1^Tx=3 and x2Tx=1x_2^Tx=1 with a new point. With b=−0.5b=-0.5 find its score.