1 / 22

Rohit Kate

Computational Intelligence in Biomedical and Health Care Informatics HCA 590 (Topics in Health Sciences). Rohit Kate. Support Vector Machines. Some slides have been adapted from Ray Mooney’s Machine Learning course at UT Austin. Reading. Section 9.3, Chapter 9, Text 3.

Download Presentation

Rohit Kate

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Computational Intelligence in Biomedical and Health Care InformaticsHCA 590 (Topics in Health Sciences) Rohit Kate Support Vector Machines Some slides have been adapted from Ray Mooney’s Machine Learning course at UT Austin.

  2. Reading • Section 9.3, Chapter 9, Text 3

  3. Support Vector Machines (SVMs) • Perhaps the most popular machine learning technique at present • Has been empirically shown to work well on many applications • Theoretically sound • Can work well with thousands of features • Resistant to overfitting the training data • It is statistical-based, and unlike rule-based methods the output is not very human-interpretable

  4. N-dimensional Points • Let n features of a machine learning task be represented by the variables x1, x2, …, xn • Then every example x=[x1,x2,..,xn] is a point in an n-dimensional space also called feature space

  5. N-dimensional Hyperplanes • In an n-dimensional space, a linear hyperplane is represented as w1x1+w2x2+…+wnxn+b=0, or in short written as wTx+b=0, where w1,w2,…,wn are called weights (T is transpose of a vector) • In two dimensions a linear hyperplane is a line; in three dimensions it’s a plane wTx + b = 0

  6. Classification Task • Given positive and negative points in an n-dimensional space find a separating hyperplane • Training: Find the hyperplane (i.e. find the w vector) • Testing: If a novel point is on the positive side of the hyperplane then classify it as positive otherwise classify it as negative

  7. Linear Separators • Binary classification can be viewed as the task of separating classes in feature space: wTx + b = 0 wTx + b > 0 wTx + b < 0 f(x) = sign(wTx + b)

  8. Linear Separators • Which of the linear separators is optimal?

  9. Classification Margin • Distance from example xi to the separator is where ||w|| is the magnitude of the vector i.e. sqrt(w1*w1+w2*w2+…+wn*wn) • Examples closest to the hyperplane are support vectors • Marginρof the separator is the distance between support vectors ρ r

  10. Maximum Margin Classification • Maximizing the margin is good according to intuition and theory • Implies that only support vectors matter; other training examples are ignorable

  11. Linear SVMs Mathematically • Let y denote the class (+1 or -1 without loss of generality) • We want a linear hyperplane such that for all training examples (xi,yi): H1: wTxi+b >= 1 for yi=+1 H2: wTxi+b <= 1 for yi=-1 Both equations can be combined as: yi(wTxi+b) >= 1 • Mathematically, the distance of any point on H1 to the separating hyperplane is 1/||w|| • Hence, margin ρ= 2/||w|| ρ H1 H2

  12. Linear SVMs Mathematically • Formulate the optimization problem (for m training examples): Which can be reformulated as: Find w and b such that is maximized and for all (xi, yi), i=1..m : yi(wTxi+ b)≥ 1 Find w and b such that Φ(w) = ||w||2=wTw is minimized and for all (xi, yi), i=1..m : yi (wTxi+ b)≥ 1

  13. Solving the Optimization Problem Find w and b such that Φ(w) =wTw is minimized and for all (xi, yi),i=1..m: yi (wTxi+ b)≥ 1 • Need to optimize a quadratic function subject to linear constraints • Quadratic optimization problems are a well-known class of mathematical programming problems for which several (non-trivial) algorithms exist • The solution involves constructing a dual problem where a Lagrange multiplierαi is associated with every inequality constraint in the primal (original) problem (skipping the mathematical details): Find α1…αmsuch that Q(α) =Σαi- ½ΣΣαiαjyiyjxiTxjis maximized and (1)Σαiyi= 0 (2) αi≥ 0 for all αi

  14. Soft Margin Classification • What if the training set is not linearly separable? • Slack variablesξican be added to allow misclassification of difficult or noisy examples, resulting margin called soft ξi ξi

  15. Soft Margin Classification Mathematically • The old formulation: • Modified formulation incorporates slack variables: • Parameter C can be viewed as a way to control overfitting: it “trades off” the relative importance of maximizing the margin and fitting the training data Find w and b such that Φ(w) =wTw is minimized and for all (xi,yi),i=1..m: yi (wTxi+ b)≥ 1 Find w and b such that Φ(w) =wTw + CΣξi is minimized and for all (xi,yi),i=1..m: yi (wTxi+ b)≥ 1 – ξi, , ξi≥ 0

  16. Linear SVMs: Overview • The classifier is a separating hyperplane. • Most “important” training points are support vectors; they define the hyperplane. • Quadratic optimization algorithms can identify which training points xiare support vectors with non-zero Lagrangian multipliers αi. • Both in the dual formulation of the problem and in the solution training points appear only inside inner products: Training (m training examples): Testing (x is the test example): f(x) = ΣαiyixiTx + b Find α1…αmsuch that Q(α) =Σαi- ½ΣΣαiαjyiyjxiTxjis maximized and (1)Σαiyi= 0 (2) 0 ≤αi≤ C for all αi

  17. Non-linear SVMs • Datasets that are linearly separable with some noise work out great: • But what are we going to do if the dataset is just too hard? • How about… mapping data to a higher-dimensional space: x 0 x 0 x2 x 0

  18. 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 linearly separable: Φ: x→φ(x)

  19. The “Kernel Trick” • The linear classifier relies on inner product between vectors K(xi,xj)=xiTxj • If every datapoint is mapped into high-dimensional space via some transformation Φ: x→φ(x), the inner product becomes: K(xi,xj)= φ(xi)Tφ(xj) • A kernel function is a function that is equivalent to an inner product in some feature space. • Example: 2-dimensional vectors x=[x1,x2]; let K(xi,xj)=(1 + xiTxj)2, Need to show that K(xi,xj)= φ(xi)Tφ(xj): K(xi,xj)=(1 + xiTxj)2,= 1+ xi12xj12 + 2 xi1xj1xi2xj2+ xi22xj22 + 2xi1xj1 + 2xi2xj2= = [1 ,xi12 ,√2 xi1xi2 , xi22 ,√2xi1 ,√2xi2]T [1 , xj12 ,√2 xj1xj2 , xj22 , √2xj1 , √2xj2] = φ(xi)Tφ(xj), where φ(x) = [1 , x12 , √2 x1x2 , x22 , √2x1 , √2x2] • Thus, a kernel function implicitly maps data to a high-dimensional space (without the need to compute each φ(x) explicitly).

  20. Examples of Kernel Functions • Linear: K(xi,xj)= xiTxj • Mapping Φ: x→ φ(x), where φ(x) is x itself • Polynomial of power p: K(xi,xj)= (1+xiTxj)p • Gaussian (radial-basis function): K(xi,xj) = • Mapping Φ: x→ φ(x), where φ(x) is infinite-dimensional: every point is mapped to a function (a Gaussian) • Linear separators in higher-dimensional space correspond to non-linear separators in original space.

  21. Non-linear SVMs Mathematically • Dual problem formulation: • The solution is: • Optimization techniques for finding αi’s remain the same! Find α1…αmsuch that Q(α) =Σαi- ½ΣΣαiαjyiyjK(xi,xj)is maximized and (1)Σαiyi= 0 (2) αi≥ 0 for all αi f(x) = ΣαiyiK(xi,xj)+ b

  22. SVM Applications • SVMs were originally proposed by Boser, Guyon and Vapnik in 1992 and gained increasing popularity in late 1990s • SVMs are currently among the best performers for a number of classification tasks ranging from text to genomic data • SVMs can be applied to complex data types beyond feature vectors (e.g. graphs, sequences, relational data) by designing kernel functions for such data • SVM techniques have been extended to regression [Vapniket al. ’97] • Most popular optimization algorithms for SVMs are SMO [Platt ’99] and by Joachims [’99] • Tuning SVMs remains a black art: selecting a specific kernel and parameters is usually done in a try-and-see manner

More Related