cosc 522 –machine learning lecture 13 –kernel methods

20
COSC 522 – Machine Learning Lecture 13 – Kernel Methods: Support Vector Machine Hairong Qi, Gonzalez Family Professor Electrical Engineering and Computer Science University of Tennessee, Knoxville http://www.eecs.utk.edu/faculty/qi Email: [email protected] Course Website: http://web.eecs.utk.edu/~hqi/cosc522/

Upload: others

Post on 02-May-2022

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: COSC 522 –Machine Learning Lecture 13 –Kernel Methods

COSC 522 – Machine Learning

Lecture 13 – Kernel Methods: Support Vector Machine

Hairong Qi, Gonzalez Family ProfessorElectrical Engineering and Computer ScienceUniversity of Tennessee, Knoxvillehttp://www.eecs.utk.edu/faculty/qiEmail: [email protected]

Course Website: http://web.eecs.utk.edu/~hqi/cosc522/

Page 2: COSC 522 –Machine Learning Lecture 13 –Kernel Methods

Recap• Supervised learning

– Classification– Baysian based - Maximum Posterior Probability (MPP): For a given x, if

P(w1|x) > P(w2|x), then x belongs to class 1, otherwise 2.– Parametric Learning

– Case 1: Minimum Euclidean Distance (Linear Machine), Si = s2I– Case 2: Minimum Mahalanobis Distance (Linear Machine), Si = S– Case 3: Quadratic classifier, Si = arbitrary– Estimate Gaussian parameters using MLE

– Nonparametric Learning– K-Nearest Neighbor

– Logistic regression– Regression

– Linear regression (Least square-based vs. ML)– Neural network

– Perceptron– BPNN

– Kernel-based approaches– Support Vector Machine

• Unsupervised learning– Kmeans, Winner-takes-all

• Supporting preprocessing techniques– Standardization, Dimensionality Reduction (FLD, PCA)

• Supporting postprocessing techniques– Performance Evaluation (confusion matrices, ROC)

2

( ) ( ) ( )( )xpPxp

xP jjj

ωωω

|| =

Page 3: COSC 522 –Machine Learning Lecture 13 –Kernel Methods

References

• Christopher J.C. Burges, “A tutorial on support vector machines for pattern recognition,” Data Mining and Knowledge Discovery, 2, 121-167, 1998

• M. Mohri, A. Rostamizadeh, A. Talwalkar, Foundations of Machine Learning, 2nd Edition, The MIT Press, 2018.

• Cortes, Corinna; Vapnik, Vladimir (1995-09-01). "Support-vector networks". Machine Learning. 20 (3): 273–297.

3

Page 4: COSC 522 –Machine Learning Lecture 13 –Kernel Methods

Questions• What does generalization and capacity mean?• What is VC dimension?• What is the principled method?• What is the VC dimension for perceptron?• What are support vectors?• What is the cost function for SVM?• What is the optimization method used?• How to handle non-separable cases using SVM?• What is kernel trick?

4

Page 5: COSC 522 –Machine Learning Lecture 13 –Kernel Methods

A bit about Vapnik

• Started SVM study in late 70s• Fully developed in late 90s• While at AT&T lab

5http://en.wikipedia.org/wiki/Vladimir_Vapnik

Page 6: COSC 522 –Machine Learning Lecture 13 –Kernel Methods

Generalization and capacity

• For a given learning task, with a given finite amount of training data, the best generalization performance will be achieved if the right balance is struck between the accuracy attained on that particular training set, and the “capacity” of the machine

• Capacity – the ability of the machine to learn any training set without error

– Too much capacity - overfitting

6

Page 7: COSC 522 –Machine Learning Lecture 13 –Kernel Methods

Bounds on the balanceUnder what circumstances, and how quickly, the mean of some empirical quantity converges uniformly, as the number of data point increases, to the true meanTrue mean error (or actual risk)

One of the bounds

7

R α( ) = 12 y− f x,α( )∫ p x, y( )dxdy

R α( ) ≤ Remp α( )+ h log 2l/h( )+1( )−log η/4( )l( ) Remp α( ) = 1

2lyi − f xi,α( )

i=1

l

f(x,a): a machine that defines a set of mappings, xàf(x,a)a: parameter or model learnedh: VC dimension that measures the capacity. non-negative integer Remp: empirical riskh: 1-h is confidence about the loss, h is between [0, 1]l: number of observations, yi: label, {+1, -1}, xi is n-D vector

Principled method: choose a learning machine that minimizes the RHS with a sufficiently small h

Page 8: COSC 522 –Machine Learning Lecture 13 –Kernel Methods

8

Page 9: COSC 522 –Machine Learning Lecture 13 –Kernel Methods

VC dimension

• For a given set of l points, there can be 2l ways to label them. For each labeling, if a member of the set {f(a)} can be found that correctly classifies them, we say that set of points is shattered by that set of functions.

• VC dimension of that set of functions {f(a)} is defined as the maximum number of training points that can be shattered by {f(a)}

• We should minimize h in order to minimize the bound

9

Page 10: COSC 522 –Machine Learning Lecture 13 –Kernel Methods

Example (f(a) is perceptron)SUPPORT VECTOR MACHINES 125

Figure 1. Three points in R2, shattered by oriented lines.

Let’s now consider hyperplanes in Rn. The following theorem will prove useful (theproof is in the Appendix):

Theorem 1 Consider some set ofm points inRn. Choose any one of the points as origin.Then the m points can be shattered by oriented hyperplanes5 if and only if the positionvectors of the remaining points are linearly independent6.

Corollary: The VC dimension of the set of oriented hyperplanes inRn is n+1, since wecan always choose n + 1 points, and then choose one of the points as origin, such that theposition vectors of the remaining n points are linearly independent, but can never choosen + 2 such points (since no n + 1 vectors in Rn can be linearly independent).An alternative proof of the corollary can be found in (Anthony and Biggs, 1995), and

references therein.

2.3. The VC Dimension and the Number of Parameters

The VC dimension thus gives concreteness to the notion of the capacity of a given setof functions. Intuitively, one might be led to expect that learning machines with manyparameters would have high VC dimension, while learning machines with few parameterswould have low VC dimension. There is a striking counterexample to this, due to E. Levinand J.S. Denker (Vapnik, 1995): A learning machine with just one parameter, but withinfinite VC dimension (a family of classifiers is said to have infinite VC dimension if it canshatter l points, no matter how large l). Define the step function θ(x), x ∈ R : {θ(x) =1 ∀x > 0; θ(x) = −1 ∀x ≤ 0}. Consider the one-parameter family of functions, definedby

f(x, α) ≡ θ(sin(αx)), x, α ∈ R. (4)

You choose some number l, and present me with the task of finding l points that can beshattered. I choose them to be:

10

Page 11: COSC 522 –Machine Learning Lecture 13 –Kernel Methods

Questions• What does generalization and capacity mean?• What is VC dimension?• What is the principled method?• What is the VC dimension for perceptron?• What are support vectors?• What is the cost function for SVM?• What is the optimization method used?• How to handle non-separable cases using SVM?• What is kernel trick?

11

Page 12: COSC 522 –Machine Learning Lecture 13 –Kernel Methods

Linear SVM – The separable case

SUPPORT VECTOR MACHINES 129

-b|w|

w

Origin

Margin

H1

H2

Figure 5. Linear separating hyperplanes for the separable case. The support vectors are circled.

xi · w+ b ≥ +1 for yi = +1 (10)xi · w+ b ≤ −1 for yi = −1 (11)

These can be combined into one set of inequalities:

yi(xi · w+ b) − 1 ≥ 0 ∀i (12)

Now consider the points for which the equality in Eq. (10) holds (requiring that thereexists such a point is equivalent to choosing a scale for w and b). These points lie on thehyperplaneH1 : xi ·w+ b = 1 with normal w and perpendicular distance from the origin|1 − b|/‖w‖. Similarly, the points for which the equality in Eq. (11) holds lie on thehyperplane H2 : xi · w+ b = −1, with normal again w, and perpendicular distance fromthe origin | − 1 − b|/‖w‖. Hence d+ = d− = 1/‖w‖ and the margin is simply 2/‖w‖.Note that H1 and H2 are parallel (they have the same normal) and that no training pointsfall between them. Thus we can find the pair of hyperplanes which gives the maximummargin by minimizing ‖w‖2, subject to constraints (12).Thus we expect the solution for a typical two dimensional case to have the form shown in

Figure 5. Those training points for which the equality in Eq. (12) holds (i.e. those whichwind up lying on one of the hyperplanes H1, H2), and whose removal would change thesolution found, are called support vectors; they are indicated in Figure 5 by the extra circles.We will now switch to a Lagrangian formulation of the problem. There are two reasons

for doing this. The first is that the constraints (12) will be replaced by constraints on theLagrange multipliers themselves, which will be much easier to handle. The second is thatin this reformulation of the problem, the training data will only appear (in the actual trainingand test algorithms) in the form of dot products between vectors. This is a crucial propertywhich will allow us to generalize the procedure to the nonlinear case (Section 4).Thus, we introduce positive Lagrange multipliers αi, i = 1, · · · , l, one for each of the

inequality constraints (12). Recall that the rule is that for constraints of the form ci ≥ 0, theconstraint equations are multiplied by positive Lagrange multipliers and subtracted from

12

xi •w+ b =1

xi •w+ b = −1

Decision boundary: w•x+ b = 0

Support vectors

Page 13: COSC 522 –Machine Learning Lecture 13 –Kernel Methods

13

xi •w+ b ≥1 for yi = +1xi •w+ b ≤ −1 for yi = −1

$%&

'&

Minimizing w 2

s.j. yi xi •w+ b( )−1≥ 0

Minimize LP = 12 w

2− αi yi xi •w+ b( )+ αi

i=1

l

∑i=1

l

∂LP∂w

= 0 ⇒ w = αi yixii∑ , ∂LP

∂b= 0 ⇒ αi yi

i∑ = 0

Maximize LD = − 12 αiα j yiyjxix ji, j∑ + αi

i∑

Page 14: COSC 522 –Machine Learning Lecture 13 –Kernel Methods

Questions• What does generalization and capacity mean?• What is VC dimension?• What is the principled method?• What is the VC dimension for perceptron?• What are support vectors?• What is the cost function for SVM?• What is the optimization method used?• How to handle non-separable cases using SVM?• What is kernel trick?

14

Page 15: COSC 522 –Machine Learning Lecture 13 –Kernel Methods

Non-separable cases

• SVM with soft margin• Kernel trick

15

Page 16: COSC 522 –Machine Learning Lecture 13 –Kernel Methods

Non-separable case – Soft margin

16

xi •w+ b ≥1−ξi for yi = +1xi •w+ b ≤ −1+ξi for yi = −1

$%&

'& for ξi ≥ 0

Minimizing w 2

s.j. yi xi •w+ b( )−1+ξi ≥ 0

Minimize LP = 12 w

2−C ξi

i∑)

*+

,

-.

k

Maximize LD = − 12 αiα j yiyjxix ji, j∑ + αi

i∑

s.j. 0 ≤αi ≤C, αi yii∑ = 0

Page 17: COSC 522 –Machine Learning Lecture 13 –Kernel Methods

Non-separable cases – The kernel trick• If there were a “kernel function”, K, s.t.

17

K xi,x j( ) =Φ xi( ) ⋅Φ x j( ) = e− xi−x j

2

2σ 2

Gaussian Radial Basis Function (RBF)

Page 18: COSC 522 –Machine Learning Lecture 13 –Kernel Methods

Comparison - XOR

18

Page 19: COSC 522 –Machine Learning Lecture 13 –Kernel Methods

Limitation

• Need to choose parameters

19

Page 20: COSC 522 –Machine Learning Lecture 13 –Kernel Methods

A toy example

20