







Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!








readings: available from class page sources: Andrew Moore http://www.cs.cmu.edu/~awm/tutorials Tom Dietterich, Andrew Ng, Michael Littman, Rich Maclin .
SVM History
z Kernel machines (a generalization of SVMs), large margin classifiers, reproducing kernel Hilbert space, Gaussian process, Boosting
Linear Classifiers
x f
α
y est
denotes + denotes -
f ( x , w ,b) = sign( w. x - b)
How would you classify this data?
Copyright © 2001, 2003, Andrew W. Moore
Linear Classifiers
x f
α
y est denotes + denotes -1 f ( x , w ,b) = sign( w. x - b)
How would you classify this data?
Copyright © 2001, 2003, Andrew W. Moore
Linear Classifiers
x f
α
y est
denotes + denotes -
f ( x , w ,b) = sign( w. x - b)
How would you classify this data?
Copyright © 2001, 2003, Andrew W. Moore
Linear Classifiers
x f
α
y est
denotes + denotes -
f ( x , w ,b) = sign( w. x - b)
How would you classify this data?
Copyright © 2001, 2003, Andrew W. Moore
Linear Classifiers
x f
α
y est
denotes + denotes -
f ( x , w ,b) = sign( w. x - b)
Any of these would be fine..
..but which is best?
Copyright © 2001, 2003, Andrew W. Moore
Classifier Margin
x f
α
y est
denotes + denotes -
f ( x , w ,b) = sign( w. x - b)
Define the margin of a linear classifier as the width that the boundary could be increased by before hitting a datapoint.
Copyright © 2001, 2003, Andrew W. Moore
Maximum Margin
x f
α
y est
denotes + denotes -
f ( x , w ,b) = sign( w. x - b)
The maximum margin linear classifier is the linear classifier with the maximum margin. This is the simplest kind of SVM (Called an LSVM)
Linear SVM
Copyright © 2001, 2003, Andrew W. Moore
Maximum Margin
x f
α
y est
denotes + denotes -
f ( x , w ,b) = sign( w. x - b)
Support Vectors are those datapoints that the margin pushes up against Copyright © 2001, 2003, Andrew W. Moore
The maximum margin linear classifier is the linear classifier with the maximum margin. This is the simplest kind of SVM (Called an LSVM)
Linear SVM
Why Maximum Margin?
denotes + denotes -
f ( x , w ,b) = sign( w. x - b)
The maximum margin linear classifier is the linear classifier with the, um, maximum margin. This is the simplest kind of SVM (Called an LSVM)
Support Vectors are those datapoints that the margin pushes up against
Plus-Plane
Minus-Plane
Classifier Boundary “Predict Class = +1”
zone
“Predict Class = -1”zone
Copyright © 2001, 2003, Andrew W. Moore
| Plus-plane = { x : w. x + b = +1 } | Minus-plane = { x : w. x + b = -1 }
Plus-Plane
Minus-Plane
Classifier Boundary “Predict Class = +1”
zone
“Predict Class = -1”zone
Classify as..
wx+b= wx+b= wx+b=-
Copyright © 2001, 2003, Andrew W. Moore
+1 if w. x + b >= 1
-1 if w. x + b <= - Universe if -1 < w. x + b < 1 explodes
| Plus-plane = { x : w. x + b = +1 } | Minus-plane = { x : w. x + b = -1 } Claim: The vector w is perpendicular to the Plus Plane. Why?
“Predict Class = +1”
zone
“Predict Class = -1”zone
wx+b= wx+b= wx+b=-
M = Margin Width
Copyright © 2001, 2003, Andrew W. Moore
| Plus-plane = { x : w. x + b = +1 } | Minus-plane = { x : w. x + b = -1 } Claim: The vector w is perpendicular to the Plus Plane. Why?
“Predict Class = +1”
zone
“Predict Class = -1”zone
wx+b= wx+b= wx+b=-
M = Margin Width
Let u and v be two vectors on the And so of course the vectorperpendicular to the Minus Plane w is alsoPlus Plane. What is w. ( u – v )?
Copyright © 2001, 2003, Andrew W. Moore
| Plus-plane = { x : w. x + b = +1 } | Minus-plane = { x : w. x + b = -1 } | The vector w is perpendicular to the Plus Plane | Let x -^ be any point on the minus plane | Let x +^ be the closest plus-plane-point to x -.
“Predict Class = +1”
zone
“Predict Class = -1”zone
wx+b= wx+b= wx+b=-
M = Margin Width
x -
x +
Any location in ¨m: not necessarily a datapoint
Any location in R m: not necessarily a datapoint
Copyright © 2001, 2003, Andrew W. Moore
| Plus-plane = { x : w. x + b = +1 } | Minus-plane = { x : w. x + b = -1 } | The vector w is perpendicular to the Plus Plane | Let x- be any point on the minus plane | Let x+ be the closest plus-plane-point to x-. | Claim: x+ = x- + λ w for some value of λ. Why?
“Predict Class = +1”
zone
“Predict Class = -1”zone
wx+b= wx+b= wx+b=-
M = Margin Width
x +
Copyright © 2001, 2003, Andrew W. Moore
| Plus-plane = { x : w. x + b = +1 } | Minus-plane = { x : w. x + b = -1 } | The vector w is perpendicular to the Plus Plane | Let x -^ be any point on the minus plane | Let x +^ be the closest plus-plane-point to x -. | Claim: x +^ = x -^ + λ w for some value of λ. Why?
“Predict Class = +1”zone
“Predict Class = -1”
wx+b=1 zone wx+b= wx+b=-
M = Margin Width
x +
The line from x-^ to x+^ is perpendicular to the planes. So to get from x-^ to x+^ travel some distance in direction w.
Copyright © 2001, 2003, Andrew W. Moore
What we know: | w. x +^ + b = + | w. x -^ + b = - | x +^ = x -^ + λ w | | x +^ - x -^ | = M It’s now easy to get M in terms of w and b
“Predict Class = +1”
zone
“Predict Class = -1”zone
wx+b= wx+b= wx+b=-
M = Margin Width
x -
x +
Copyright © 2001, 2003, Andrew W. Moore
What we know: | w. x +^ + b = + | w. x -^ + b = - | x +^ = x -^ + λ w | | x +^ - x -^ | = M It’s now easy to get M in terms of w and b
“Predict Class = +1”
zone
“Predict Class = -1”zone
wx+b= wx+b= wx+b=-
M = Margin Width
x -
x +
Copyright © 2001 2003 Andrew W Moore
What we know: w. x +^ + b = + w. x -^ + b = - x +^ = x -^ + λ w | x +^ - x -^ | = M
“Predict Class = +1”
zone
“Predict Class = -1”
wx+b=1 zone wx+b= wx+b=-
M = Margin Width =
x -
x +
w.w
λ =
w. w
2
Copyright © 2001, 2003, Andrew W. Moore
Given a guess of w and b we can | Compute whether all data points are in the correct half-planes | Compute the width of the margin So now we just need to write a program to search the space of w ’s and b ’s to find the widest margin that matches all the datapoints. How? Gradient descent? Simulated Annealing? Matrix Inversion? EM? Newton’s Method?
“Predict Class = +1”zone
“Predict Class = -1”zone
wx+b= wx+b= wx+b=-
M = Margin Width =
x -
x +^ w. w
2
Copyright © 2001, 2003, Andrew W. Moore
Don’t worry… it’s good for you…
Don’t worry… it’s good for you…
There are fast algorithms for solving linear programs including the simplex algorithm and Karmarkar’s algorithm
Uh-oh!
denotes + denotes -
This is going to be a problem!
What should we do? Idea 1:
minimizing number of training set errors. Problem: Two things to minimize makes for an ill- defined optimization
Copyright © 2001, 2003, Andrew W. Moore
Uh-oh!
denotes + denotes -
This is going to be a problem!
What should we do? Idea 1.1: Minimize
There’s a serious practical problem that’s about to make us reject this approach. Can you guess what it is?
Tradeoff parameter
Copyright © 2001, 2003, Andrew W. Moore
Uh-oh!
denotes + denotes -
This is going to be a problem! What should we do? Idea 1.1:
Minimize
There’s a serious practical problem that’s about to make us reject this approach. Can you guess what it is?
Tradeoff parameter Can’t be expressed as a Quadratic Programming problem. Solving it may be too slow. (Also, doesn’t distinguish between disastrous errors and near misses) So… any other ideas?
Copyright © 2001, 2003, Andrew W. Moore
Uh-oh!
denotes + denotes -
This is going to be a problem! What should we do? Idea 2.0:
Minimize
Copyright © 2001, 2003, Andrew W. Moore
Given guess of w , b we can | Compute sum of distances of points to their correct zones | Compute the margin width Assume R datapoints, each ( x k ,y (^) k ) where y (^) k = +/- 1
wx+b= wx+b= wx+b=-
w. w
2
What should our quadratic optimization criterion be?
How many constraints will we have? What should they be?
Copyright © 2001, 2003, Andrew W. Moore
Given guess of w , b we can | Compute sum of distances of points to their correct zones | Compute the margin width Assume R datapoints, each ( x k ,y (^) k ) where y (^) k = +/- 1
wx+b= wx+b= wx+b=-
w. w
2
What should our quadratic optimization criterion be?
How many constraints will we have? What should they be?
Copyright © 2001, 2003, Andrew W. Moore
Given guess of w , b we can | Compute sum of distances of points to their correct zones | Compute the margin width Assume R datapoints, each ( x k ,y (^) k ) where y (^) k = +/- 1
wx+b= wx+b= wx+b=-
w. w
2
What should our quadratic optimization criterion be? Minimize
=
R
k
1
How many constraints will we have? R What should they be? w. x k + b >= 1- ε k if y (^) k = 1 w. x k + b <= -1+ ε k if y (^) k = -
Copyright © 2001, 2003, Andrew W. Moore
Given guess of w , b we can | Compute sum of distances of points to their correct zones | Compute the margin width Assume R datapoints, each ( x k ,y (^) k ) where y (^) k = +/- 1
wx+b= wx+b= wx+b=-
w. w
2
What should our quadratic optimization criterion be? Minimize
=
R
k
1
m = # input dimensions
How many constraints will we have? R What should they be? w. x k + b >= 1- ε k if y (^) k = 1 w. x k + b <= -1+ ε k if y (^) k = -
R= # records
Copyright © 2001, 2003, Andrew W. Moore
How many constraints will we have? R What should they be? w. x k + b >= 1- ε k if y (^) k = 1 w. x k + b <= -1+ ε k if y (^) k = -
Given guess of w , b we can | Compute sum of distances of points to their correct zones | Compute the margin width Assume R datapoints, each ( x k ,y (^) k ) where y (^) k = +/- 1
wx+b= wx+b= wx+b=-
w. w
2
What should our quadratic optimization criterion be? Minimize
=
R
k
1
There’s a bug in this QP. Can you spot it? Copyright © 2001, 2003, Andrew W. Moore
Given guess of w , b we can | Compute sum of distances of points to their correct zones | Compute the margin width Assume R datapoints, each ( x k ,y (^) k ) where y (^) k = +/- 1
wx+b= wx+b= wx+b=-
w. w
2
What should our quadratic optimization criterion be? Minimize
How many constraints will we have? 2R What should they be? w. x k + b >= 1- ε k if y (^) k = 1 w. x k + b <= -1+ ε k if y (^) k = - ε k >= 0 for all k
=
R
k
1
Copyright © 2001, 2003, Andrew W. Moore
= = =
R
k
R
l
k l kl
R
k
Subject to these constraints:
Then define:
=
R
k
1
k k
K K K K
Then classify with: f ( x , w ,b) = sign( w. x - b)
1
=
R
k
Copyright © 2001, 2003, Andrew W. Moore
Remember how permitting non- linear basis functions made linear regression so much nicer? Let’s permit them here too
2
Copyright © 2001, 2003, Andrew W. Moore
Copyright © 2001, 2003, Andrew W. Moore
⎟⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎠
⎞
⎜⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎝
⎛
=
m − m
m
m
m
m
x x
xx
xx
xx
xx
xx
x
x
x
x
x
x
1
1
23
1
13
12
2
22
12
2
1
2
:
2
:
2
2
:
2
2
:
2
:
2
2
1
Φ ( x )
Constant Term
Linear Terms
Pure Quadratic Terms
Quadratic Cross-Terms
Number of terms (assuming m input dimensions) = (m+2)-choose- = (m+2)(m+1)/ = (as near as makes no difference) m 2 /
You may be wondering what those ’s are doing. •You should be happy that they do no harm •You’ll find out why they’re there soon.
Copyright © 2001, 2003, Andrew W. Moore
Subject to these constraints:
Then define:
k k
K K K K
Then classify with:
1
=
R
k
s.t. 0
k α k
= = =
R
k
R
l
k l kl
R
k
Copyright © 2001, 2003, Andrew W. Moore
Subject to these constraints:
Then define:
k k
K K K K
Then classify with:
1
=
R
k
We must do R 2 /2 dot products to get this matrix ready. Each dot product requires m^2 / additions and multiplications The whole thing costs R^2 m^2 /4. Yeeks! …or does it?…or does it?
s.t. 0
k α k
= = =
R
k
R
l
k l kl
R
k
Copyright © 2001, 2003, Andrew W. Moore
⎟⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎠
⎞
⎜⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎝
⎛
⎟⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎠
⎞
⎜⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎝
⎛
− m − m
m
m
m
m
m m
m
m
m
m
b b
bb
bb
bb
bb
bb
b
b
b
b
b
b
a a
aa
aa
aa
aa
aa
a
a
a
a
a
a
1
1
23
1
13
12
2
(^22)
12
2
1
1
1
23
1
13
12
2
22
12
2
1
2
:
2
:
2
2
:
2
2
:
2
:
2
2
1
2
:
2
:
2
2
:
2
2
:
2
:
2
2
1
Φ ( a ) Φ ( b )
1
=
m i
ai bi 1
2
m i i^ i
ab 1
22
m i
m ji i^ jij
aabb 1 1
2
Copyright © 2001, 2003, Andrew W. Moore
Φ ( a )• Φ ( b ) =
m i
m ji ijij
m i ii
m i i^ i
a b ab aabb 1 1 1
22 1
12 2
Just out of casual, innocent, interest, let’s look at another function of a and b : ( a. b + 1 )^2 = ( a. b )^2 + 2 a. b + 1
2 1 1
2 1
⎟+ + ⎠
⎜ ⎞ ⎝
= ⎛
m i ii
m i i^ i
ab ab
2 1 1 1 1
= = =
m i ii
m i
m j i^ ijj
abab ab
( ) 2 2 1 1 1 1 1
= = =+ =
m i
ii
m i
m ji
iijj
m i
ai bi abab ab
Copyright © 2001, 2003, Andrew W. Moore
Φ ( a )• Φ ( b ) =
Just out of casual, innocent, interest, let’s look at another function of a and b : ( a. b + 1 )^2 = ( a. b )^2 + 2 a. b + 1
2 1 1
2 1
⎟+ + ⎠
⎜ ⎞ ⎝
= ⎛
m i ii
m i i^ i
ab ab
2 1 1 1 1
= = =
m i ii
m i
m j i^ ijj
abab ab
( ) 2 2 1 1 1 1 1
= = =+ =
m i
ii
m i
m ji
iijj
m i
ai bi abab ab
They’re the same! And this is only O(m) to compute!
m i
m ji ijij
m i ii
m i i^ i
a b ab aabb 1 1 1
22 1
12 2
Copyright © 2001, 2003, Andrew W. Moore
Subject to these constraints:
Then define:
k k
K K K K
Then classify with:
1
=
R
k
We must do R 2 /2 dot products to get this matrix ready. Each dot product now only requires m additions and multiplications
s.t. 0
k α k
= = =
R
k
R
l
k l kl
R
k
Copyright © 2001, 2003, Andrew W. Moore
All m^4 /24 m^4 R 2 /48 1,960,000 R 2 ( a. b +1) 4 m R 2 / 2 50 R 2 terms up to degree 4
Quartic
All m^3 /6 terms m^3 R 2 /12 83,000 R 2 ( a. b +1) 3 m R 2 / 2 50 R 2 up to degree 3
Cubic
All m^2 /2 terms m^2 R 2 /4 2,500 R 2 ( a. b +1) 2 m R 2 / 2 50 R 2 up to degree 2
Quadratic
Cost if 100 inputs
Cost to build Q (^) kl matrix efficiently
Cost if 100 φ ( a ). φ ( b ) inputs
Cost to build Q (^) kl matrix traditionally
Polynomial φ ( x )
Copyright © 2001, 2003, Andrew W. Moore
= = =
R
k
R
l
k l kl
R
k
1 1 1
Subject to these constraints:
Then define:
s.t. 0
k α k
k k
K K K K
Then classify with:
1
=
R
k
We must do R^2 /2 dot products to get this matrix ready. In 100-d, each dot product now needs 103 operations instead of 75 million But there are still worrying things lurking away. What are they?
Copyright © 2001, 2003, Andrew W. Moore
= = =
R
k
R
l
k l kl
R
k
1 1 1
Subject to these constraints:
Then define:
s.t. 0
k α k
k k
K K K K
Then classify with:
1
=
R
k
We must do R^2 /2 dot products to get this matrix ready. In 100-d, each dot product now needs 103 operations instead of 75 million But there are still worrying things lurking away. What are they? •The fear of overfitting with this enormous number of terms •The evaluation phase (doing a set of predictions on a test set) will be very expensive(why?)
Copyright © 2001, 2003, Andrew W. Moore
Key SVM Ideas
SVM Performance
Copyright © 2001, 2003, Andrew W. Moore
Doing multi-class classification
z SVM 1 learns “Output==1” vs “Output != 1” z SVM 2 learns “Output==2” vs “Output != 2” z : z SVM N learns “Output==N” vs “Output != N”
Copyright © 2001, 2003, Andrew W. Moore
SVM Implementations
References
C. Burges. A tutorial on support vector machines for pattern recognition. Data Mining and Knowledge Discovery, 2(2):955-974, 1998. http://citeseer.nj.nec.com/burges98tutorial.html
Statistical Learning Theory by Vladimir Vapnik, Wiley-Interscience; 1998
Copyright © 2001, 2003, Andrew W. Moore