Machine Learning and Data Mining. Support Vector Machines. Kalev Kask

Similar documents
Support Vector Machine (SVM) & Kernel CE-717: Machine Learning Sharif University of Technology. M. Soleymani Fall 2012

Kernel Machines. Pradeep Ravikumar Co-instructor: Manuela Veloso. Machine Learning

Support Vector Machine (SVM) and Kernel Methods

Statistical Machine Learning from Data

Support Vector Machine (SVM) and Kernel Methods

Support Vector Machines: Maximum Margin Classifiers

Jeff Howbert Introduction to Machine Learning Winter

Support Vector Machine (SVM) and Kernel Methods

Introduction to Support Vector Machines

Support Vector Machine (continued)

Kernel Methods and Support Vector Machines

(Kernels +) Support Vector Machines

Perceptron Revisited: Linear Separators. Support Vector Machines

Support Vector Machines. CSE 6363 Machine Learning Vassilis Athitsos Computer Science and Engineering Department University of Texas at Arlington

Kernels and the Kernel Trick. Machine Learning Fall 2017

Pattern Recognition 2018 Support Vector Machines

LECTURE 7 Support vector machines

Linear vs Non-linear classifier. CS789: Machine Learning and Neural Network. Introduction

CS798: Selected topics in Machine Learning

Review: Support vector machines. Machine learning techniques and image analysis

Linear classifiers selecting hyperplane maximizing separation margin between classes (large margin classifiers)

Max Margin-Classifier

SVMs, Duality and the Kernel Trick

Non-Bayesian Classifiers Part II: Linear Discriminants and Support Vector Machines

Announcements - Homework

ML (cont.): SUPPORT VECTOR MACHINES

CSE546: SVMs, Dual Formula5on, and Kernels Winter 2012

Machine Learning. Support Vector Machines. Manfred Huber

Linear classifiers selecting hyperplane maximizing separation margin between classes (large margin classifiers)

Support Vector Machines

Support Vector Machines

Support Vector Machines

Topics we covered. Machine Learning. Statistics. Optimization. Systems! Basics of probability Tail bounds Density Estimation Exponential Families

Support Vector Machines

Foundation of Intelligent Systems, Part I. SVM s & Kernel Methods

CSC 411 Lecture 17: Support Vector Machine

Pattern Recognition and Machine Learning. Perceptrons and Support Vector machines

Machine Learning Support Vector Machines. Prof. Matteo Matteucci

Support Vector Machines. Introduction to Data Mining, 2 nd Edition by Tan, Steinbach, Karpatne, Kumar

Support vector machines Lecture 4

Lecture Support Vector Machine (SVM) Classifiers

Support Vector Machines, Kernel SVM

Kernelized Perceptron Support Vector Machines

CS145: INTRODUCTION TO DATA MINING

Cheng Soon Ong & Christian Walder. Canberra February June 2018

Support Vector Machines for Classification and Regression. 1 Linearly Separable Data: Hard Margin SVMs

Kernel Methods. Barnabás Póczos

Support Vector Machines and Kernel Methods

Support Vector Machines and Kernel Methods

Linear, threshold units. Linear Discriminant Functions and Support Vector Machines. Biometrics CSE 190 Lecture 11. X i : inputs W i : weights

SUPPORT VECTOR MACHINE

Support Vector Machines. CSE 4309 Machine Learning Vassilis Athitsos Computer Science and Engineering Department University of Texas at Arlington

Lecture 9: Large Margin Classifiers. Linear Support Vector Machines

Support Vector Machines

About this class. Maximizing the Margin. Maximum margin classifiers. Picture of large and small margin hyperplanes

Linear & nonlinear classifiers

Support Vector Machines

10701 Recitation 5 Duality and SVM. Ahmed Hefny

10/05/2016. Computational Methods for Data Analysis. Massimo Poesio SUPPORT VECTOR MACHINES. Support Vector Machines Linear classifiers

Linear classifiers selecting hyperplane maximizing separation margin between classes (large margin classifiers)

Linear & nonlinear classifiers

Introduction to Machine Learning Prof. Sudeshna Sarkar Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Data Mining - SVM. Dr. Jean-Michel RICHER Dr. Jean-Michel RICHER Data Mining - SVM 1 / 55

Introduction to SVM and RVM

EE613 Machine Learning for Engineers. Kernel methods Support Vector Machines. jean-marc odobez 2015

Machine Learning : Support Vector Machines

Support Vector Machines for Classification and Regression

Support Vector Machines

Convex Optimization and Support Vector Machine

Lecture 10: A brief introduction to Support Vector Machine

Kernel Methods. Machine Learning A W VO

Support Vector Machines.

L5 Support Vector Classification

Linear Classification and SVM. Dr. Xin Zhang

Support Vector Machine

CS6375: Machine Learning Gautam Kunapuli. Support Vector Machines

Support Vector Machine

Support Vector Machines

Applied inductive learning - Lecture 7

Machine Learning Basics Lecture 4: SVM I. Princeton University COS 495 Instructor: Yingyu Liang

Lecture 18: Kernels Risk and Loss Support Vector Regression. Aykut Erdem December 2016 Hacettepe University

Lecture 10: Support Vector Machine and Large Margin Classifier

Support Vector Machines II. CAP 5610: Machine Learning Instructor: Guo-Jun QI

Data Mining. Linear & nonlinear classifiers. Hamid Beigy. Sharif University of Technology. Fall 1396

Support Vector Machine for Classification and Regression

COMP 652: Machine Learning. Lecture 12. COMP Lecture 12 1 / 37

Support Vector Machines (SVM) in bioinformatics. Day 1: Introduction to SVM

LINEAR CLASSIFICATION, PERCEPTRON, LOGISTIC REGRESSION, SVC, NAÏVE BAYES. Supervised Learning

Support Vector Machines and Speaker Verification

Outline. Basic concepts: SVM and kernels SVM primal/dual problems. Chih-Jen Lin (National Taiwan Univ.) 1 / 22

Support Vector Machines Explained

Learning From Data Lecture 25 The Kernel Trick

Support'Vector'Machines. Machine(Learning(Spring(2018 March(5(2018 Kasthuri Kannan

Machine Learning. Lecture 6: Support Vector Machine. Feng Li.

Support Vector Machine & Its Applications

Support Vector Machines. Maximizing the Margin

Lecture 18: Optimization Programming

Support Vector Machines for Regression

Kernels. Machine Learning CSE446 Carlos Guestrin University of Washington. October 28, Carlos Guestrin

Basis Expansion and Nonlinear SVM. Kai Yu

Transcription:

Machine Learning and Data Mining Support Vector Machines Kalev Kask

Linear classifiers Which decision boundary is better? Both have zero training error (perfect training accuracy) But, one of them seems intuitively better How can we quantify better, and learn the best parameter settings? Feature 2, x 2 Feature 2, x 2 Decision boundary Decision boundary Feature 1, x 1 Feature 1, x 1

Overview Separable data Linear (hard margin) SVM Hard margin Nearly separable data Linear (soft margin) SVM Soft margin Non-separable data Non-linear SVM Kernel SVM Hard/Soft margin

Math tech pt #1 q. x +T 0 q. x +T = C X + q. x +T = 1 margin M

Math tech pt #2 Notation change! Vector w=[w 1 w 2 ] is perpendicular to the boundaries (why?) w x + b = 0 & w x + b = 0 => w (x -x) = 0 : orthogonal U V = U V cos(a) f(x)=0 f(x) = +1 Region +1 f(x) = -1 Region -1 x x w margin M

Separable SVM Notation change! Maybe we want to maximize our margin To optimize, relate to model parameters Remove scale invariance Define class +1 in some region, class 1 in another Make those regions as far apart as possible f(x)=0 f(x) = +1 Region +1 We could define such a function: f(x) = -1 f(x) = w*x + b f(x) > +1 in region +1 f(x) < 1 in region 1 Passes through zero in center Region -1 Support vectors data points on margin

Computing the margin width Vector w=[w 1 w 2 ] is perpendicular to the boundaries Choose x st f(x ) = -1; let x + be the closest point with f(x + ) = +1 x + = x + r * w (why?) Closest two points on the margin also satisfy w x - + b = -1 w x + + b = +1 f(x)=0 f(x) = +1 x+ Region +1 f(x) = -1 rw x w Region -1 margin M

Computing the margin width Vector w=[w 1 w 2 ] is perpendicular to the boundaries Choose x st f(x ) = -1; let x + be the closest point with f(x + ) = +1 x + = x + r * w Closest two points on the margin also satisfy w x - + b = -1 w x + + b = +1 f(x)=0 f(x) = +1 x+ Region +1 f(x) = -1 rw x w Region -1 margin M

Maximum margin classifier Constrained optimization Get all data points correct Maximize the margin This is an example of a quadratic program: quadratic cost function, linear constraints such that all data on the correct side of the margin f(x)=0 f(x) = +1 Region +1 Primal problem: f(x) = -1 s.t. w Region -1 margin M (m constraints)

Maximum margin classifier Constrained optimization Get all data points correct Maximize the margin This is an example of a quadratic program: quadratic cost function, linear constraints such that all data on the correct side of the margin f(x)=0 f(x) = +1 Region +1 Primal problem: f(x) = -1 s.t. w Region -1 margin M (m constraints)

A 1D Example Suppose we have three data points x = -3, y = -1 x = -1, y = -1 x = 2, y = 1 Many separating perceptrons, T[ax+b] Anything with ax+b = 0 between -1 and 2 We can write the margin constraints a (-3) + b < -1 => b < 3a - 1 a (-1) + b < -1 => b < a - 1 a (2) + b > +1 => b > -2a + 1-3 -1 2 b x a

A 1D Example Suppose we have three data points x = -3, y = -1 x = -1, y = -1 x = 2, y = 1 Many separating perceptrons, T[ax+b] Anything with ax+b = 0 between -1 and 2 We can write the margin constraints a (-3) + b < -1 => b < 3a - 1 a (-1) + b < -1 => b < a - 1 a (2) + b > +1 => b > -2a + 1 Ex: a = 1, b = 0-3 -1 2 b x a

A 1D Example Suppose we have three data points x = -3, y = -1 x = -1, y = -1 x = 2, y = 1 Many separating perceptrons, T[ax+b] Anything with ax+b = 0 between -1 and 2 We can write the margin constraints a (-3) + b < -1 => b < 3a - 1 a (-1) + b < -1 => b < a - 1 a (2) + b > +1 => b > -2a + 1 Ex: a = 1, b = 0 Minimize a => a =.66, b = -.33 Two data on the margin; constraints tight -3-1 2 b x a

Machine Learning and Data Mining Support Vector Machines: Lagrangian and Dual Kalev Kask

Lagrangian optimization Want to optimize constrained system: s.t. θ = (w,b) f(θ) g i (θ) 0 Introduce Lagrange multipliers α (one per constraint) Can optimize θ, α i jointly, with a simple constraint set Then: Any optimum of the original problem is a saddle point of the new problem KKT complementary slackness:

Optimization Use Lagrange multipliers Enforce inequality constraints w L= w α i y (j) x (i) L/ b = - α i y (j) f(x)=0 f(x) = +1 f(x) = -1 Region +1 Alphas > 0 only on the margin: support vectors Stationary conditions wrt w: w and since any support vector has y = wx + b, Region -1 margin M

Dual form Use Lagrange multipliers Enforce inequality constraints Use solution w* to write solely in terms of alphas: s.t. (since derivative wrt b = 0) f(x)=0 f(x) = +1 f(x) = -1 Region +1 Another quadratic program: optimize m vars with 1+m (simple) constraints cost function has m 2 dot products w Region -1 margin M

Nearly separable SVM What if the data are not linearly separable? Want a large margin : Want low error: Soft margin : introduce slack variables for violated constraints s.t. (violate margin by ²) Assigns cost R proportional to distance from margin Another quadratic program!

Soft margin SVM Large margin vs. Slack variables s.t. R large = hard margin R smaller A few wrong predictions; boundary farther from rest R = R 0 R = 10-2 R 0 R = 10-4 R 0

Maximum margin classifier Soft margin optimization: For any weights w, we can choose ε to satisfy constraints Write ε* as a function of w (call this J) and optimize directly J = distance from the correct place (hinge loss) (L2 regularization on the weights) +1 J=0

Dual form Soft margin dual: K ij measures similarity of x i and x j (their dot product) s.t. K = Gram matrix f(x)=0 f(x) = +1 f(x) = -1 Region +1 Support vectors now data on or past margin Prediction: Region -1 More complicated; can solve e.g. using any 2 (0,R)

Machine Learning and Data Mining Support Vector Machines: The Kernel Trick Kalev Kask

Linear SVMs So far, looked at linear SVMs: Expressible as linear weights w Linear decision boundary f(x)=0 f(x) = +1 f(x) = -1 Region +1 w Dual optimization for a linear SVM: Region -1 s.t. Depend on pairwise dot products: Kij measures similarity, e.g., 0 if orthogonal

Adding features Linear classifier can t learn some functions 1D example: x 1 Not linearly separable Add quadratic features x 2 = (x 1 ) 2 Linearly separable in new features x 1

Adding features Recall: feature function Phi(x) Predict using some transformation of original features Dual form of SVM optimization is: s.t. For example, quadratic (polynomial) features: Ignore root-2 scaling for now Expands x to length O(n 2 )

Implicit features Need Can evaluate dot product in only O(n) computations!

Mercer Kernels If K(x,x ) satisfies Mercer s condition: For all datasets X: Then, for some Notably, Phi may be hard to calculate May even be infinite dimensional! Only matters that K(x,x ) is easy to compute: Computation always stays O(m 2 )

Common kernel functions Some commonly used kernel functions & their shape: Polynomial K(x,x ) 0 x=1

Common kernel functions Some commonly used kernel functions & their shape: Polynomial Radial Basis Functions K(x,x ) ¾ = 1 0 x=1

Common kernel functions Some commonly used kernel functions & their shape: Polynomial Radial Basis Functions Saturating, sigmoid-like: K(x,x ) c=1, h=0 0 x=1

Common kernel functions Some commonly used kernel functions & their shape: Polynomial Radial Basis Functions Saturating, sigmoid-like: Many for special data types: String similarity for text, genetics In practice, may not even be Mercer kernels

Kernel SVMs Linear SVMs Can represent classifier using (w,b) = n+1 parameters Or, represent using support vectors, x (i) Kernelized? K(x,x ) may correspond to high (infinite?) dimensional Phi(x) Typically more efficient to remember the SVs Instance based save data, rather than parameters Contrast: Linear SVM: identify features with linear relationship to target Kernel SVM: identify similarity measure between data (Sometimes one may be easier; sometimes the other!)

Kernel Least-squares Linear Regression Recall L2-regularized linear regression: Rearranging, Define: Rearrange & solve for r: Gram matrix: m x m, Linear prediction: Now just replace K(x,x ) with your desired kernel function!

Example: Kernel Linear Regression K: MxM Linear kernel: Gaussian (RBF) kernel:

Summary Support vector machines Large margin for separable data Primal QP: maximize margin subject to linear constraints Lagrangian optimization simplifies constraints Dual QP: m variables; involves m 2 dot product Soft margin for non-separable data Primal form: regularized hinge loss Dual form: m-dimensional QP Kernels Dual form involves only pairwise similarity Mercer kernels: dot products in implicit high-dimensional space