Support Vector Machine
Support Vector Machine
1
2
3
4
5
6
7
8
9
10
11
12
13
Classification: Definition
• Given a collection of records (training set )
– Each record contains a set of attributes, one of the attributes is
the class label.
14
Classification Example
height
x1
x x X 2
weight 2
Training examples {( x1 , y1 ), , (x l , yl )}
H if (w x) b 0
q(x)
J if (w x) b 0
y J (w x) b 0
15
x1
Linear Classifiers
f(x,w,b) = sign(w x + b)
denotes +1
denotes -1
Any of these
would be fine..
..but which is
best?
16
Support Vector Machine
x+ M=Margin Width
Support Vectors
are those
datapoints that
X-
the margin
pushes up
against
What we know:
• w . x+ + b = +1 (x x ) w 2
• w . x- + b = -1 M
• w . (x+-x-) = 2 w w
17
Linear SVM Mathematically
• Goal: 1) Correctly classify all training data
wx i b 1 if yi = +1
wx i b 1 If yi = -1
yi ( wxi b) 1 for all i
2
2) Maximize the Margin M
w
1 t
same as minimize ww
2
• We can formulate a Quadratic Optimization Problem and solve for w and b
1 t
Minimize ( w) w w
2
subject to
yi (wxi b) 1 i
18
Linear SVM. Cont.
• Requiring the derivatives with respect to w,b to vanish yields:
m
1 m m
maximize
i 1
i
2 i 1 j 1
i j y i j i j
y x ,x
m
Subject to : i 0
y
i 1
i
i 0 i
• KKT conditions yield:
for any i 0, b y i w, x i
• Where:
m
w i y x i i
i 1 19
Linear SVM. Cont.
• The resulting separating function is:
m
f x i y i x i , x b
i 1
20
Linear SVM. Cont.
• The resulting separating function is:
m
f x i y i x i , x b
i 1
• Notes:
– The points with α=0 do not affect the solution.
– The points with α≠0 are called support vectors.
– The equality conditions hold true only for the
Support Vectors.
21
Non-linear SVMs: Feature spaces
• General idea: the original feature space can always be
mapped to some higher-dimensional feature space
where the training set is separable:
Φ: x → φ(x)
22
Non Linear SVM
• Note that the training data appears in the solution only in inner
products.
k ( x, y ) x, y 1
p
• Non-homogeneous Polynomial Kernels:
31
Solution of non-linear SVM
• The problem:
,x
m
1 m m
maximize
i 1
i
2 i 1 j 1
i j y i j
y k x i j
m
Subject to : i 0
y
i 1
i
sgn f x sgn i y i k x i , x b
m
i 1
32
33
34
35
36
37
38