Skip to content

Chapter 12 Formula Sheet

One page for the whole chapter. Equation numbers are the book’s; the measured columns are this module’s, computed on the eight-point running example unless stated otherwise. Chapter 12 prints no numbers of its own — it has no worked examples — so every value here was produced by these pages.

X=[3131616110010110],y=(+1,+1,+1,+1,1,1,1,1)\mathbf{X} = \begin{bmatrix}3&1\\3&-1\\6&1\\6&-1\\1&0\\0&1\\0&-1\\-1&0\end{bmatrix}, \qquad \mathbf{y} = (+1,+1,+1,+1,-1,-1,-1,-1)
quantityexact value
w\mathbf{w}^*, bb^*(1,0)(1, 0), 2-2
w\lVert\mathbf{w}^*\rVert, margin rr11, 11
support vectors(3,1)(3,1), (3,1)(3,-1), (1,0)(1,0)33 of 88
α\boldsymbol\alpha(14,14,0,0,12,0,0,0)(\tfrac14, \tfrac14, 0, 0, \tfrac12, 0, 0, 0)
closest hull points c\mathbf{c}, d\mathbf{d}(3,0)(3, 0), (1,0)(1, 0); cd=2\lVert\mathbf{c}-\mathbf{d}\rVert = 2

Four routes to one classifier.

§12.2.1§12.2.2§12.3.1§12.3.2
what is fixedw=1\lVert\mathbf{w}\rVert = 1value 11 at the closest point
what is optimisedmaxr\max rmin12w2\min\tfrac12\lVert\mathbf{w}\rVert^2min\min over α\boldsymbol\alphamincd\min\lVert\mathbf{c}-\mathbf{d}\rVert
variablesD+2D + 2D+1D + 1NNNN
convexno (a sphere)yesyesyes
equation12.1012.2112.4112.48
they agree to7.492×1067.492\times10^{-6} degrees over 300300 datasets, and 9.185×1089.185\times10^{-8} in w\mathbf{w}
whatequation
the taskf:RD{+1,1}f : \mathbb{R}^D \to \{+1, -1\}12.1
the modelf(x)=w,x+bf(\mathbf{x}) = \langle\mathbf{w},\mathbf{x}\rangle + b12.2a, 12.2b
the hyperplane{x:f(x)=0}\{\mathbf{x} : f(\mathbf{x}) = 0\}12.3
w\mathbf{w} is normal to itf(xa)f(xb)=w,xaxbf(\mathbf{x}_a) - f(\mathbf{x}_b) = \langle\mathbf{w},\mathbf{x}_a - \mathbf{x}_b\rangle12.4a, 12.4b
correct classificationw,xn+b0\langle\mathbf{w},\mathbf{x}_n\rangle + b \geq 0 if yn=+1y_n = +1; <0< 0 if yn=1y_n = -112.5, 12.6
combinedyn(w,xn+b)0y_n(\langle\mathbf{w},\mathbf{x}_n\rangle + b) \geq 012.7
whatequation
vector additionxa=xa+rww\mathbf{x}_a = \mathbf{x}_a' + r\,\dfrac{\mathbf{w}}{\lVert\mathbf{w}\rVert}12.8
both classes at onceyn(w,xn+b)ry_n(\langle\mathbf{w},\mathbf{x}_n\rangle + b) \geq r12.9
the problemmaxw,b,rr\max_{\mathbf{w},b,r} r s.t. 12.9, w=1\lVert\mathbf{w}\rVert = 1, r>0r > 012.10

rr is a signed coordinate along w/w\mathbf{w}/\lVert\mathbf{w}\rVert: measured on all eight points, r\lvert r\rvert equals the distance to the projection to 0.000×1000.000\times10^{0}, and the sign gives the side. With w=1\lVert\mathbf{w}\rVert = 1, f(x)f(\mathbf{x}) is that coordinate.

§12.2.2–12.2.3 Setting the margin to one

Section titled “§12.2.2–12.2.3 Setting the margin to one”
whatequation
the projection is on the hyperplanew,xa+b=0\langle\mathbf{w},\mathbf{x}_a'\rangle + b = 012.11
substitute 12.812.12, expand by bilinearity — 12.13
the marginr=1wr = \dfrac{1}{\lVert\mathbf{w}\rVert}12.14
the constraintyn(w,xn+b)1y_n(\langle\mathbf{w},\mathbf{x}_n\rangle + b) \geq 112.15
maximise the reciprocal12.16, 12.17
the hard margin SVMminw,b12w2\min_{\mathbf{w},b}\tfrac12\lVert\mathbf{w}\rVert^2 s.t. 12.1512.18, 12.19
Theorem 12.112.10 and 12.21 are equivalent — 12.20, 12.21
the proof’s hingew=1/r\lVert\mathbf{w}''\rVert = 1/r12.24, checked to 1.137×10131.137\times10^{-13}
whatequation
geometric viewmin12w2+Cnξn\min \tfrac12\lVert\mathbf{w}\rVert^2 + C\sum_n\xi_n s.t. ynf(xn)1ξny_n f(\mathbf{x}_n) \geq 1-\xi_n, ξn0\xi_n \geq 012.26a–c
the hypothesis classf(x)=w,x+bf(\mathbf{x}) = \langle\mathbf{w},\mathbf{x}\rangle + b12.27
the hinge loss(t)=max{0,1t}\ell(t) = \max\{0, 1-t\}, t=yf(x)t = yf(\mathbf{x})12.28
as two pieces00 if t1t \geq 1, else 1t1-t12.29
the hard margin’s loss00 if t1t \geq 1, else \infty12.30
loss viewmin12w2regularizer+Cnmax{0,1ynf(xn)}error term\min \underbrace{\tfrac12\lVert\mathbf{w}\rVert^2}_{\text{regularizer}} + C\sum_n\underbrace{\max\{0, 1-y_nf(\mathbf{x}_n)\}}_{\text{error term}}12.31
why they are the samemintmax{0,1t}minξ,tξ\min_t\max\{0,1-t\} \equiv \min_{\xi,t}\xi s.t. ξ0\xi\geq0, ξ1t\xi\geq1-t12.32, 12.33
ξn\xi_nwhere the example is
00correct, at or beyond its margin — costs nothing
(0,1](0, 1]correct side, inside the margin
>1> 1wrong side of the hyperplane
whatequation
the LagrangianL=12w2+Cξnαn(ynf(xn)1+ξn)γnξn\mathfrak{L} = \tfrac12\lVert\mathbf{w}\rVert^2 + C\sum\xi_n - \sum\alpha_n(y_nf(\mathbf{x}_n)-1+\xi_n) - \sum\gamma_n\xi_n12.34
the three derivatives12.35, 12.36, 12.37
the representer theoremw=nαnynxn\mathbf{w} = \sum_n \alpha_n y_n \mathbf{x}_n12.38
substituting back12.39, 12.40
the dual SVMminα12i,jyiyjαiαjxi,xjiαi\min_{\boldsymbol\alpha}\tfrac12\sum_{i,j}y_iy_j\alpha_i\alpha_j\langle\mathbf{x}_i,\mathbf{x}_j\rangle - \sum_i\alpha_i s.t. iyiαi=0\sum_i y_i\alpha_i = 0, 0αiC0 \leq \alpha_i \leq C12.41
recovering the interceptb=ynw,xnb^* = y_n - \langle\mathbf{w}^*,\mathbf{x}_n\rangle12.42
the KKT conditions, which the book gives only as a margin note
αn=0\alpha_n = 0ynf(xn)1y_nf(\mathbf{x}_n) \geq 1
0<αn<C0 < \alpha_n < Cynf(xn)=1y_nf(\mathbf{x}_n) = 1
αn=C\alpha_n = Cynf(xn)1y_nf(\mathbf{x}_n) \leq 1
whatequation
the convex hullconv(X)={nαnxn}\mathrm{conv}(\mathcal{X}) = \{\sum_n\alpha_n\mathbf{x}_n\}, nαn=1\sum_n\alpha_n = 1, αn0\alpha_n \geq 012.43
the difference vectorw:=cd\mathbf{w} := \mathbf{c} - \mathbf{d}12.44
the objectiveargminw=argmin12w2\arg\min\lVert\mathbf{w}\rVert = \arg\min\tfrac12\lVert\mathbf{w}\rVert^212.45
the two pointsc=yn=+1αn+xn\mathbf{c} = \sum_{y_n=+1}\alpha_n^{+}\mathbf{x}_n, d=yn=1αnxn\mathbf{d} = \sum_{y_n=-1}\alpha_n^{-}\mathbf{x}_n12.46, 12.47
in hull coordinates12.48
each hull sums to one12.49, which multiplies out to nynαn=0\sum_n y_n\alpha_n = 012.50, 12.51
the soft margin’s geometrythe reduced hull, with every weight capped
whatequation
a kernelk(xi,xj)=ϕ(xi),ϕ(xj)Hk(\mathbf{x}_i,\mathbf{x}_j) = \langle\boldsymbol\phi(\mathbf{x}_i),\boldsymbol\phi(\mathbf{x}_j)\rangle_{\mathcal{H}}12.52
the requirementz:zKz0\forall\mathbf{z} : \mathbf{z}^\top\mathbf{K}\mathbf{z} \geq 012.53
the canonical feature mapϕ(x)=k(,x)\boldsymbol\phi(\mathbf{x}) = k(\cdot, \mathbf{x})
the substitutionreplace xi,xj\langle\mathbf{x}_i,\mathbf{x}_j\rangle in 12.41 by k(xi,xj)k(\mathbf{x}_i,\mathbf{x}_j)
kernelfeature dimensionGram rank at N=50800N = 50 \dots 800
polynomial, degree 22(D+22)=6\binom{D+2}{2} = 66,6,6,6,66, 6, 6, 6, 6
polynomial, degree 33101010,10,10,10,1010, 10, 10, 10, 10
polynomial, degree 55212121,21,21,21,2121, 21, 21, 21, 21
RBF, γ=0.5\gamma = 0.5infinite50,93,125,154,17150, 93, 125, 154, 171
RBF, γ=5.0\gamma = 5.0infinite50,100,200,392,59750, 100, 200, 392, 597

The polynomial ranks saturate exactly and never move again; the RBF’s never level off. That is what having no finite feature map looks like from outside, and γ\gamma controls how fast the space fills up.

whatequation
the subgradientg(t)=1g(t) = -1 for t<1t<1; any value in [1,0][-1,0] at t=1t=1; 00 for t>1t>112.54
the primal, standard formD+1+ND + 1 + N variables, 2N2N constraints — 12.55, 12.56
the dual, standard formNN variables, 2N+22N + 2 constraint rows — 12.57
an equality as two inequalitiesAx=bAxb\mathbf{A}\mathbf{x} = \mathbf{b} \Rightarrow \mathbf{A}\mathbf{x}\leq\mathbf{b} and b\geq\mathbf{b}12.58
measuredvalue
subgradient set at t=1t = 1exactly [1,0][-1, 0]; unique elsewhere
subgradient descent, 10510^5 iterationsgap 4.091×1044.091\times10^{-4} — the O(1/k)O(1/\sqrt{k}) rate
12.56 solved against the reference7.105×10157.105\times10^{-15}
12.57 solved against the reference2.132×10142.132\times10^{-14}
generic SLSQP against LIBSVM89×89\times at N=200N=200, 49,548×\mathbf{49{,}548\times} at N=2000N=2000

With an RBF kernel the primal has infinitely many variables and the dual has NN. The dual is not merely smaller there — it is the only one of the two that exists.

quantityvaluepage
w,xaxb\langle\mathbf{w},\mathbf{x}_a-\mathbf{x}_b\rangle on the hyperplane0.000×1000.000\times10^{0}, 200,000200{,}000 pairs1201
separating hyperplanes sampled9,6289{,}628 of 400,000400{,}0001201
their held-out accuracyworst 0.87570.8757, best 0.98770.9877, spread 0.11190.11191201
correlation, margin against accuracy0.5909990.5909991201
max-margin accuracy, and its rank0.98530.9853; beats 91.76%91.76\%1201
the Bayes rate for that generator0.98760.9876 at x=2.25x = 2.251201
worst accuracy per margin bin0.87570.97770.8757 \to 0.97771201
r=1/wr = 1/\lVert\mathbf{w}\rVert3.553×10153.553\times10^{-15}, 20,00020{,}000 draws1202, 1203
isotropic rescale: boundary2.0000002.000000 at every cc1202
margin as an intruder entersmin{1,(3t)/2}\min\{1, (3-t)/2\}; infeasible at t=3t = 31202
12.10 vs 12.21, convergence failures251/2000251/2000 against 0/20000/20001202
squaring the norm: change in argmin4.441×10164.441\times10^{-16}1203
Theorem 12.1 over 300300 datasets7.492×1067.492\times10^{-6} degrees; 11 non-convergence1203
Equation 12.241.137×10131.137\times10^{-13}, 50,00050{,}000 draws1203
w\lVert\mathbf{w}\rVert vs 12w2\tfrac12\lVert\mathbf{w}\rVert^2, 500500 starts33 failures, 2929 iterations against 00 and 551203
soft margin recovers hard marginexactly by C=1C = 1; bb=0\lvert b-b^*\rvert = 01204
C0C \to 0wC\lVert\mathbf{w}\rVert \propto C; margin 800800 at C=104C = 10^{-4}1204
translation invariance, bb free1.993×10151.993\times10^{-15}1204
translation invariance, bb penalisedobjective moves 10.48\mathbf{10.48}1204
the knife edge at small CClabels decided by f=±1.2×1015f = \pm1.2\times10^{-15}1204
the exact zero-one optimum11 error at w=(1,0)\mathbf{w} = (1,0), b=3b = -31205
12.31 against 12.264.45×10134.45\times10^{-13} or better1205
hinge boundary with a distant outlier2.0000002.000000, unchanged at every distance1205
squared-loss boundary, same outlier2.333.972.33 \to 3.97; 22 examples misclassified1205
the dual multipliers(14,14,0,0,12,0,0,0)(\tfrac14,\tfrac14,0,0,\tfrac12,0,0,0) to 1.075×1081.075\times10^{-8}1206
w2=αn\lVert\mathbf{w}\rVert^2 = \sum\alpha_n4.782×1084.782\times10^{-8}, 200200 datasets1206
adding 500500 easy examplesstill 33 support vectors; 8.289×10128.289\times10^{-12} of mass1206
duality gap1.8×1013\leq 1.8\times10^{-13} across five CC1206
the margin note at C=2C = 2on-margin examples have αn=C\alpha_n = C1206
closest hull pointsc=(3,0)\mathbf{c} = (3,0), d=(1,0)\mathbf{d} = (1,0), distance 221207
hull-to-SVM conversion, 200200 datasets9.185×1089.185\times10^{-8}, 4.282×1084.282\times10^{-8}, 5.051×10115.051\times10^{-11}1207
hull weights vs multipliers5.780×1085.780\times10^{-8}1207
the reduced hullcd\lVert\mathbf{c}-\mathbf{d}\rVert 2.004.402.00 \to 4.40; class means 4.54.5 apart1207
polynomial feature dimension at D=1000D=1000, p=5p=58,459,043,543,9518{,}459{,}043{,}543{,}9511208
Gram rank saturation66, 1010, 2121 at every NN1208
RBF Gram rank5017150 \to 171 (γ=0.5\gamma=0.5); 5059750 \to 597 (γ=5\gamma=5)1208
tanh\tanh smallest eigenvalue55.44-55.44, 1010 of 120120 negative1208
four kernels on two rings0.64170.6417, 1.00001.0000, 1.00001.0000, 1.00001.00001208
support vectors, linear against degree 22120120 against 6\mathbf{6}1208
subgradient descent, 10510^5 stepsgap 4.091×1044.091\times10^{-4}1209
both standard-form QPs7.105×10157.105\times10^{-15}, 2.132×10142.132\times10^{-14}1209
generic solver against LIBSVM89×89\times, 12,349×12{,}349\times, 49,548×49{,}548\times1209
max-margin percentile over 192192 datasets84.11%84.11\%; best on 661210
a change of units0.26380.2638 of held-out accuracy1210
standardising firstspread falls to 0.00290.00291210
leave-one-out bound0.03330.0333 against 0.00000.0000; 0.55000.5500 against 0.23330.23331210
CC‘s good plateaufour orders of magnitude1210
γ=0.01\gamma = 0.01 across CC0.71430.99650.7143 \to 0.99651210
γ=100\gamma = 100 across CCnever above 0.83750.83751210
SVM scores outside [1,1][-1, 1]74.40%74.40\%1210
deleting non-support vectorsSVM 0.0000000.000000; logistic offset 0.5371670.5371671210
1010 positives against 200200 negativesrecall 0.0000\mathbf{0.0000}1210
  1. Chapter 12 reasons geometrically, not probabilistically — closer to Chapter 10’s derivation of PCA than to Chapter 9’s likelihood — and prints no numbers at all.
  2. A hyperplane is a set, and a set does not fix its parameters. Distance has no meaning until a scale is chosen, which is what §12.2.1 and §12.2.2 each do differently.
  3. Zero training error picks nothing. Thousands of separators fit perfectly and disagree by more than ten points of held-out accuracy.
  4. The margin raises the floor rather than the ceiling. It lands at the 84th percentile every time and is almost never the best available.
  5. Theorem 12.1’s two formulations agree to seven millionths of a degree, and only one of them is convex — which is why nobody solves Equation 12.10.
  6. Slack makes the problem always solvable, and C is the price of a violation, running backwards from the usual regularisation convention.
  7. Leaving b unregularised is what makes the answer independent of where the origin sits. Penalising it moves the objective by 10.48 under a shift.
  8. The hinge is a convex upper bound on the zero-one loss that reaches exactly zero, and that is the property from which everything else follows.
  9. Because the loss reaches zero, most multipliers are zero. Five of eight examples are deletable and five hundred more are addable, both without changing the answer.
  10. The dual’s size depends on N and never on D, which is the only reason an infinite-dimensional feature map is usable at all.
  11. The same problem read geometrically is: find the two closest points of the two convex hulls, and bisect the segment. The margin is half its length.
  12. Scaling a feature is pricing it, and the chapter never mentions standardising — a quarter of a point of accuracy rests on a decision it does not discuss.

Back to the start: Classification Overview

pch.coffeeTagline

pch.coffeeCta

pch.feedbackHeading

pch.feedbackSubheading