Week 6 SVM
Week 6 SVM
Nigel Goddard
School of Informatics
Semester 1
1 / 18
Outline
2 / 18
Overview
3 / 18
Stuff You Need to Remember
w> x is length of the projection of x onto w (if w is a unit vector)
w b
i.e., b = wT x.
x2
o o
o o
o o
o
w o o
x o
o
x x
x
x
x x x1
x
5 / 18
A Crap Decision Boundary
6 / 18
Idea: Maximize the Margin
The margin is the distance between the decision boundary (the
hyperplane) and the closest training point.
x
o x
o x x
o o
~
w margin
o
7 / 18
Computing the Margin
I The tricky part will be to get an equation for the margin
I We’ll start by getting the distance from the origin to the
hyperplane
I i.e., We want to compute the scalar b below
w
b
wTx + w0 = 0
8 / 18
Computing the Distance to Origin
So
w
b =z
||w||
9 / 18
Computing the Distance to Origin
w
I We know that (a) z on the hyperplane and (b) b ||w|| = z.
I First (a) means wT z + w0 = 0
I Substituting we get
bw
wT + w0 = 0
||w||
bwT w
+ w0 = 0
||w||
w0
b=−
||w||
√
I Remember ||w|| = wT w.
I Now we have the distance from the origin to the
hyperplane!
10 / 18
Computing the Distance to Hyperplane
x c
w
a
b
11 / 18
Computing the Distance to Hyperplane
x c
w
a
b
1
|wT x + w0 |
||w||
I The margin is the distance from the closest training point
to the hyperplane
1
min |wT xi + w0 |
i ||w||
13 / 18
The Scaling
min |w> xi + w0 | = 1
i
14 / 18
First version of Max Margin Optimization Problem
I Here is a first version of an optimization problem to
maximize the margin (we will simplify)
max 1/||w||
w
subject to w> xi + w0 ≥ 0 for all i with yi = 1
>
w xi + w0 ≤ 0 for all i with yi = −1
>
min |w xi + w0 | = 1
i
I The first two constraints are too lose. It’s the same thing to
say
max 1/||w||
w
subject to w> xi + w0 ≥ 1 for all i with yi = 1
w> xi + w0 ≤ −1 for all i with yi = −1
>
min |w xi + w0 | = 1
i
I Now the third constraint is redundant 15 / 18
First version of Max Margin Optimization Problem
max 1/||w||
w
subject to w> xi + w0 ≥ 1 for all i with yi = 1
>
w xi + w0 ≤ −1 for all i with yi = −1
max 1/||w||
w
subject to yi (w> xi + w0 ) ≥ 1 for all i
16 / 18
The SVM optimization problem
min ||w||2
w
s.t. yi (w> xi + w0 ) ≥ +1 for all i
17 / 18
Fin (Part I)
18 / 18