Linear & nonlinear classifiers

Similar documents
Linear & nonlinear classifiers

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

Cheng Soon Ong & Christian Walder. Canberra February June 2018

Support Vector Machine (continued)

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

Support Vector Machine (SVM) and Kernel Methods

Support Vector Machine (SVM) and Kernel Methods

Pattern Recognition 2018 Support Vector Machines

Statistical Machine Learning from Data

Kernel Methods and Support Vector Machines

Support Vector Machine

Machine Learning. Support Vector Machines. Manfred Huber

Max Margin-Classifier

Support Vector Machines and Kernel Methods

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

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

Support Vector Machines

Mark your answers ON THE EXAM ITSELF. If you are not sure of your answer you may wish to provide a brief explanation.

Machine Learning Support Vector Machines. Prof. Matteo Matteucci

Introduction to Support Vector Machines

Perceptron Revisited: Linear Separators. Support Vector Machines

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

Support Vector Machine (SVM) and Kernel Methods

Jeff Howbert Introduction to Machine Learning Winter

Lecture 9: Large Margin Classifiers. Linear Support Vector Machines

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

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

(Kernels +) Support Vector Machines

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

LINEAR CLASSIFIERS. J. Elder CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition

Lecture Notes on Support Vector Machine

Statistical Pattern Recognition

Support Vector Machines: Maximum Margin Classifiers

Support Vector Machine

CS798: Selected topics in Machine Learning

Machine Learning Practice Page 2 of 2 10/28/13

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

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

Support Vector Machines, Kernel SVM

Learning with kernels and SVM

Neural Networks. Prof. Dr. Rudolf Kruse. Computational Intelligence Group Faculty for Computer Science

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

Kernel Methods. Machine Learning A W VO

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

Pattern Recognition and Machine Learning. Perceptrons and Support Vector machines

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

Machine Learning Lecture 7

Support Vector Machines

ML (cont.): SUPPORT VECTOR MACHINES

Support Vector Machines.

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

CS6375: Machine Learning Gautam Kunapuli. Support Vector Machines

Classification CE-717: Machine Learning Sharif University of Technology. M. Soleymani Fall 2012

NONLINEAR CLASSIFICATION AND REGRESSION. J. Elder CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition

Machine Learning Lecture 5

Support Vector Machines

Linear Models for Classification

Indirect Rule Learning: Support Vector Machines. Donglin Zeng, Department of Biostatistics, University of North Carolina

Introduction to SVM and RVM

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

Modelli Lineari (Generalizzati) e SVM

COMS 4721: Machine Learning for Data Science Lecture 10, 2/21/2017

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

ESS2222. Lecture 4 Linear model

L5 Support Vector Classification

Support Vector Machines Explained

Constrained Optimization and Support Vector Machines

Chapter 9. Support Vector Machine. Yongdai Kim Seoul National University

CS145: INTRODUCTION TO DATA MINING

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

Support Vector Machines for Classification and Regression

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

Linear Classification and SVM. Dr. Xin Zhang

Support Vector Machines

CIS 520: Machine Learning Oct 09, Kernel Methods

SVMs: Non-Separable Data, Convex Surrogate Loss, Multi-Class Classification, Kernels

Discriminative Models

Support Vector Machine & Its Applications

Support Vector Machines for Classification: A Statistical Portrait

Lecture 16: Modern Classification (I) - Separating Hyperplanes

Support Vector Machines

Announcements - Homework

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

Support Vector Machines

Brief Introduction to Machine Learning

Lecture 10: A brief introduction to Support Vector Machine

A short introduction to supervised learning, with applications to cancer pathway analysis Dr. Christina Leslie

Reading Group on Deep Learning Session 1

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

SUPPORT VECTOR MACHINE

Discriminative Models

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

CSC 411 Lecture 17: Support Vector Machine

SVMs, Duality and the Kernel Trick

Chemometrics: Classification of spectra

Midterm Review CS 6375: Machine Learning. Vibhav Gogate The University of Texas at Dallas

ICS-E4030 Kernel Methods in Machine Learning

Support Vector Machines and Kernel Methods

Midterm. Introduction to Machine Learning. CS 189 Spring You have 1 hour 20 minutes for the exam.

Transcription:

Linear & nonlinear classifiers Machine Learning Hamid Beigy Sharif University of Technology Fall 1394 Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 1 / 34

Table of contents 1 Introduction 2 Linear classifiers through origin 3 Logistic regression 4 Perceptron algorithm 5 Support vector machines 6 Non-linear support vector machine 7 Generalized linear classifier Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 2 / 34

Introduction In classification, the goal is to find a mapping from inputs X to outputs t {1, 2,..., C} given a labeled set of input-output pairs (training set) S = {(x 1, t 1 ), (x 2, t 2 ),..., (x N, t N )}. Each training input x is a D dimensional vector of numbers. Approaches for building a classifier. Generative approach: This approach first creates a joint model of the form of p(x, C n ) and then to condition on x, then deriving p(c n x). Discriminative approach: This approach creates a model of the form of p(c n x) directly. Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 3 / 34

Linear classifiers through origin We consider the following type of linear classifiers. y(x n ) = g(x n ) = sign(w 1 x n1 + w 2 x n2 +... + w D x nd ) { 1, +1} D ) = sign w n x nj = sign (w T x n. j=1 w = (w 1, w 2,..., w D ) T is a column vector of real valued parameters (w R D ). Different value of w give different functions. x n = (x n1, x n2,..., x nd ) T is a column vector of real values. This classifier changes its prediction only when the argument to the sign function changes from positive to negative (or vice versa). Geometrically,this transition in the feature space corresponds to crossing the decision boundary where the argument is exactly zero: all x such that w T x = 0. Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 4 / 34

Logistic regression In linear regression, we often assume that the noise has a Gaussian distribution. p(t x, w) = N (t µ(x), σ 2 (x)) We can generalize the linear regression to binary classification by making two changes: Replacing the Gaussian distribution for t with Bernoulli distribution, which is more appropriate for classification. p(t x, w) = Ber(t µ(x)) = { µ(x) if t = 1 1 µ(x) if t = 0 where µ(x) = E[t x] = p(t = 1 x). We compute a linear combination of the inputs but then we pass through a function that ensures 0 µ(x) 1 by defining. µ(x) = sigm(w T x) where sigm(x) refers to sigmoid function. 1 1 + exp( w T x). Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 5 / 34

Logistic regression (cont.) Putting these two steps together, we obtain p(t x, w) = Ber(t sigm(w T x)). This is called logistic regression due to its similarity to linear regression. If we threshold the output probability at 1 2, we can introduce a decision rule of the form if p(t = 1 x) > 0.5 g(x) = 1. Logistic regression learns weights so as to maximize the (log-)likelihood of the data. Let S = {(x 1, t 1 ), (x 2, t 2 ),..., (x N, t N )} be the training set. The negative log-likelihood of data equals L(w) = log = N µ(x) I [t] (1 µ(x)) I [tn=0] N I [t n = 1] log µ(x) + I [t n = 0] log(1 µ(x)) This is called the cross-entropy error function. Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 6 / 34

Logistic regression (cont.) Let t n { 1, +1}. Another way to write the log-likelihood of data is. p(y = +1 x) = p(y = 1 x) = 1 1 + exp( w T x) 1 1 + exp(+w T x) By combining the above equations and computing negative log-likelihood of data, we obtain L(w) = = N 1 log 1 + exp( t n w T x n ) N [ ] log 1 + exp( t n w T x n ) Unlike linear regression, we can no longer write down the minimum of negative log-likelihood in the closed form. Instead, we need to use an optimization algorithm for computing it. Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 7 / 34

Logistic regression (cont.) Computing the gradients of L(w) with respect to w, we obtain L(w) w i = N t n x ni sigm( t n w T x n ) Updating the weight vector using the gradient descent rule will result in w (k+1) i = w (k) i + η N t n x ni sigm( t n w T x n ) η is the learning rate. In order to have a good trade-off between the training error and the generalization error, we can add the regularization term. L(w) = N [ ] log 1 + exp( t n w T x n ) + λ 2 w 2 Using the gradient descent rule, will result in the following updating rule. w (k+1) i = w (k) i + η N t n x ni sigm( t n w T x n ) ηλw (k) i Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 8 / 34

The Perceptron algorithm We would like to find a linear classifier that makes the fewest mistakes on the training set. In other words, we want find w that minimizes the training error E E (w) = 1 N = 1 N N (1 δ(t n, g(x n ))) N L (t n, g(x n )). δ(t, t ) = 1 if t = t and 0 otherwise. L is loss function called zero one loss. What would be a reasonable algorithm for setting the parameters w? We can just incrementally adjust the parameters so as to correct any mistakes that the corresponding classifier makes. Such an algorithm would seem to reduce the training error that counts the mistakes. The simplest algorithm of this type is the Perceptron update rule. We consider each training instances one by one, cycling through all the training instances, and adjust the parameters according to (drive it.) w = w + t n x n if t n g(x n ) In other words, the parameters (classifier) is changed only if we make a mistake. These updates tend to correct mistakes. Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 9 / 34

The Perceptron algorithm (cont.) The parameters (classifier) is changed only if we make a mistake. To see this, When we make a mistake sign(w T x k ) t k. The inequality t k w T x k < 0 is hold. Consider w after updating t n w T x = t n (w + t n x n ) T x n = t n w T x n + t 2 nx T n x n = t n w T x n + x n 2 This means that, the value of t k w T x n increases as a result of the update (becomes more positive). If we consider the same feature vector repeatedly, then we will necessarily change the parameters such that the vector is classified correctly, i.e., the value of t k w T x n becomes positive. if the training examples are possible to classify correctly with a linear classifier, will the Perceptron algorithm find such a classifier? Yes, it does, and it will converge to such a classifier in a finite number of updates (mistakes). To drive this result (an alternative proof), please read section 3.3 of Pattern Recognition Book by Theodoridis and Koutroumbas Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 10 / 34

The Perceptron algorithm (cont.) We considered the linearly separable case in which the following inequality holds. t n (w ) T x n > 0 for all n = 1, 2,..., N W is the weight learned by the Perceptron algorithm. Now assume we want to learn a hyperplane that classifies the training set with margin of γ > 0, i.e. we have t n (w ) T x n > γ for all n = 1, 2,..., N Parameter γ > 0 is used to ensure that each example is classified correctly with a finite margin. Theorem When x n R for all n and some finite R, the Perceptron algorithm needs at most ( ) 2 R γ w 2 updates of the weight vector (w). Outline of proof. The convergence proof is based on combining the following two results, 1 The inner product (w ) T w (k) increases at least linearly with each update. 2 The squared norm w (k) 2 increases at most linearly in the number of updates k. Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 11 / 34

The Perceptron algorithm (cont.) We now give details of each part. Proof of part 1. 1 The weight vector w updated when the training instance is not classified correctly. We consider the inner product (w ) T w (k) before and after each update. (w ) T w (k) = (w ) T ( w (k 1) + t n x n ) = (w ) T w (k 1) + t n (w ) T x n (w ) T w (k 1) + γ (w ) T w (k 2) + 2γ (w ) T w (k 3) + 3γ. (w ) T w (0) + kγ = kγ Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 12 / 34

The Perceptron algorithm (cont.) We now give details of part 2. Proof of part 2. 1 The weight vector w updated when the training instance is not classified correctly. We consider w (k) 2 before and after each update. w (k) 2 = w (k 1) 2 + t n x n = w (k 1) 2 ( + 2tn w (k 1)) T xn + t n x n 2 = w (k 1) 2 ( + 2tn w (k 1)) T xn + x n 2 w (k 1) 2 + xn 2 w (k 1) 2 + R 2 w (k 2) 2 + 2R 2. w (0) 2 + kr 2 = kr 2 Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 13 / 34

The Perceptron algorithm (cont.) We now combine two parts. Combination of parts 1 & 2. 1 The cos(x, y) measures the similarity of x and y. update. ( cos w, w (k)) = 1 2 (w ) T w (k) (w ) T w (k) kγ (w ) T w (k) kγ kr2 (w ) T 1 2 The last inequality is because the cos is bounded by one. Hence, we have k kr2 (w ) T γ ( ) 2 R (w ) T 2 γ Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 14 / 34

The Perceptron algorithm : margin and geometry Does w 2 γ relate to the difficulty of the classification problem? γ Yes, its inverse ( ) is the smallest distance in the feature space from any example to w 2 the decision boundary specified by w. In other words, it is a measure of separation of two classes. This distance is called geometric distance and denoted by γ geom. In order to calculate the geometric distance (γ geom ), the distance from the decision boundary ((w ) T x = 0) to one of the examples x n for which t n (w ) T x n = γ is measured. Since w is normal to the decision boundary, the shortest path from the boundary to the instance x n will be parallel to the normal. The instance for which t n (w ) T x n = γ is therefore among those closest to the boundary. Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 15 / 34

The Perceptron algorithm : margin and geometry Let x be an arbitrary point and let x be its orthogonal projection onto the decision surface. Let r be the distance between x and x. If g(x) = +1, we have If g(x) = 1, we have w x x = r w w x x = r w Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 16 / 34

The Perceptron algorithm : margin and geometry Hence, by combining the two last equations we obtain x = x + r tw w x = x r tw w It remains to find the value of r such that (w ) T x = 0. This is the point where the segment hits the decision boundary. Thus, we have [ 0 = t(w ) T x = t(w ) T x r tw ] w = t(w ) T x r t2 (w ) T w w = t(w ) T x r w 2 }{{} w γ Hence, we obtain 0 = γ r w r = γ w Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 17 / 34

The Perceptron algorithm : margin and geometry Hence, the number of updates for w is equal to k ( R γ geom ) 2 Note that the result does not depend (directly) on the dimension (D) of the examples, nor the number of training examples (N). The value of γ geom can be interpreted as a measure of difficulty (or complexity) of the problem of learning linear classifiers in this setting. There are other variants of perceptron algorithm such as normalized perceptron algorithm and Pocket algorithm. please study them. We have assumed that there exists a linear classifier that has a large geometric margin.this type of classifier is called large margin classifier. We have so far used a simple iterative algorithm (perceptron algorithm) to find the linear classifier. Can we find a large margin classifier directly? Yes, we can find the large margin classifier directly. This classifier is known as the support vector machine (SVM). Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 18 / 34

Support vector machines Consider the problem of finding a separating hyperplane for a linearly separable dataset S = {(x 1, t 1 ), (x 2, t 2 ),..., (x N, t N )} with x i R D and t i { 1, +1}. Which of the infinite hyperplanes should we choose? Hyperplanes that pass too close to the training examples will be sensitive to noise and, therefore, less likely to generalize well for data outside the training set. It is reasonable to expect that a hyperplane that is farthest from all training examples will have better generalization capabilities. We can find the maximum margin linear classifier by first identifying a classifier that correctly classifies all the examples and then increasing the geometric margin until we cannot increase the margin any further. We can also set up an optimization problem for directly maximizing the geometric margin. Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 19 / 34

Support vector machines (cont.) We will need the classifier to be correct on all the training examples (t n w T x n γ for all n = 1, 2,..., N) subject to these constraints, we would like to maximize the geometric margin ( γ w ). Hence, we have Maximize γ w We can alternatively minimize the inverse w γ same constraints. Minimize 1 w 2 2 γ 2 subject to t n w T x n γ for all n = 1, 2,..., N or the inverse squared w 2 γ 2 subject to t n w T x n γ for all n = 1, 2,..., N subject to the Factor 1 2 is included merely for later convenience. The above problem can be written as Minimize 1 w 2 ( ) T 2 γ subject to t w n γ xn 1 for all n = 1, 2,..., N This problem tells the dependency on the ration w γ not w or γ separately. Scaling w by a constant also doesnt change the decision boundary. We can therefore fix γ = 1 and solve for w. Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 20 / 34

Support vector machines (cont.) By fixing γ = 1 and solving for w, we obtain Minimize 1 2 w 2 subject to t n w T x n 1 for all n = 1, 2,..., N This optimization problem is in the standard SVM form and is a quadratic programming problem. We will modify the linear classifier here slightly by adding an offset term so that the decision boundary does not have to go through the origin. In other words, the classifier that we consider has the form g(x) = w T x + b w is the weight vector b is the bias of the separating hyperplane. The hyperplane is shown by (w, b). The bias parameter changes the optimization problem to Minimize 1 2 w 2 subject to t n ( w T x n + b ) 1 for all n = 1, 2,..., N Note that the bias only appears in the constraints. This is different from simply modifying the linear classifier through origin by feeding it with examples that have an additional constant component, i.e., x = [x; 1]. Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 21 / 34

Support vector machines (cont.) The optimization problem for SVM is defined as Minimize 1 2 w 2 subject to t n ( w T x n + b ) 1 for all n = 1, 2,..., N In order to solve this constrained optimization problem, we introduce Lagrange multipliers α n 0, with one multiplier α n for each of the constraints giving the Lagrangian function L(w, b, α) = 1 N [ ) ] 2 w 2 α n t n (w T x n + b 1 where α = (α 1, α 2,..., α N ) T. Note the minus sign in front of the Lagrange multiplier term, because we are minimizing with respect to w and b, and maximizing with respect to α. please read Appendix E of Bishop. Setting the derivatives of L(w, b, α) with respect to w and b equal to zero, we obtain the following two equations L N w = 0 w = α n t n x n L N b = 0 0 = α n t n Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 22 / 34

Support vector machines (cont.) L has to be minimized with respect to the primal variables w and b and maximized with respect to the dual variables α n. Eliminating w and b from L(w, b, a) using these conditions then gives the dual representation of the problem in which we maximize N L(α) = α n 1 N N α n α m t n t m xn T x m 2 m=1 We need to maximize L(α) subject to the following constraints α n 0 n N α n t n = 0 The constrained optimization of this form satisfies the Karush-Kuhn-Tucker (KKT) conditions, which in this case require that the following three properties hold α n 0 t n g(x n ) 1 α n [t n g(x n ) 1] = 0 To classify a data x using the trained model, we evaluate the sign of g(x) defined by N g(x) = α n t n xn T x Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 23 / 34

Support vector machines (cont.) We have assumed that the training data are linearly separable in the feature space. The resulting SVM will give exact separation of the training data. In the practice, the class-conditional distributions may overlap, in which the exact separation of the training data can lead to poor generalization. We need a way to modify the SVM so as to allow some training examples to be miss-classified. To do this, we introduce slack variables (ξ n 0); one slack variable for each training example. The slack variables are defined by ξ n = 0 for examples that are inside the correct boundary margin and ξ n = t n g(x n ) for other examples. Thus for data point that is on the decision boundary g(x n ) = 0 will have ξ n = 1 and the data points with ξ n 1 will be misclassified. Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 24 / 34

Support vector machines (cont.) The exact classification constraints will be t n g(x n ) 1 ξ n for n = 1, 2,..., N Our goal is now to maximize the margin while softly penalizing points that lie on the wrong side of the margin boundary. We therefore minimize C N ξ n + 1 2 w 2 C > 0 controls the trade-off between the slack variable penalty and the margin. We now wish to solve the following optimization problem. Minimize 1 2 w 2 + C N ξ n The corresponding Lagrangian is given L(w, b, α) = 1 2 w 2 + C subject to t n g(x n ) 1 ξ n for all n = 1, 2,..., N N ξ n N α n [t n g(x n ) 1 + ξ n ] where α n 0 and β n 0 are Lagrange multipliers. please read section 7.1.1 of Bishop. N β n ξ n Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 25 / 34

Non-linear support vector machine Most data sets are not linearly separable, for example Instances that are not linearly separable in 1 dimension, may be linearly separable in 2 dimensions, for example In this case, we have two solutions Increase dimensionality of data set by introducing mapping φ. Use a more complex model for classifier. Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 26 / 34

Non-linear support vector machine (cont.) To solve the non-linearly separable dataset, we use mapping φ. For example, let x = (x 1, x 2 ) T, z = (z 1, z 2.z 3 ) T, and φ : R 2 R 3. If we use mapping z = φ(x) = (x 2 1, 2x 1 x 2, x 2 2 )T, the dataset will be linearly separable in R 3. Mapping dataset to higher dimensions has two major problems. In high dimensions, there is risk of over-fitting. In high dimensions, we have more computational cost. The generalization capability in higher dimension is ensured by using large margin classifiers. The mapping is an implicit mapping not explicit. Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 27 / 34

Non-linear support vector machine (cont.) The SVM uses the following discriminant function. N g(x) = α n t n xn T x This solution depends on the dot-product between two pints x i and x j. The operation in high dimensional space φ(x) don t have performed explicitly if we can find a function K(x i, x j ) such that K(x i, x j ) = φ(x i ) T φ(x j ). K(x i, x j ) is called kernel in the SVM. Suppose x, z R D and consider the following kernel ( ) 2 K(x, z) = x T z It is a valid kernel because K(x, z) = = where the mapping φ for D = 2 is ( D i=1 D i=1 j=1 x i z i ) D x j z j j=1 D (x i x j ) (z i z j ) = φ(x) T φ(z) φ(x) = (x 1 x 1, x 1 x 2, x 2 x 1, x 2 x 2 ) T Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 28 / 34

Non-linear support vector machine (cont.) Show that kernel K(x, z) = (x T z + c) 2 is a valid kernel. A kernel K is valid if there is some mapping φ such that K(x, z) = φ(x) T φ(z). Assume that K is a valid kernel. Consider a set of N points, K is N N square matrix defined as K = k(x 1, x 1 ) k(x 1, x 2 ) k(x 1, x N ) k(x 2, x 1 ) k(x 2, x 2 ) k(x 2, x N )...... k(x N, x 1 ) k(x N, x 2 ) k(x N, x N ) K is called kernel matrix. If K is a valid kernel then k ij = k(x i, x j ) = φ(x i ) T φ(x j ) = φ(x j ) T φ(x i ) = k(x j, x i ) = k ji Thus K is symmetric. It can also be shown that K is positive semi-definite (show it.). Thus if K is a valid kernel, then the corresponding kernel matrix is symmetric positive semi-definite. It is both necessary and sufficient conditions for K to be a valid kernel. Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 29 / 34

Non-linear support vector machine (cont.) Theorem (Mercer) Assume that K : R D R D R. Then for K to be a valid (Mercer) kernel, it is necessary and sufficient that for any {x 1, x 2,..., x N }, (N > 1) the corresponding kernel matrix is symmetric positive semi-definite. Some valid kernel functions Polynomial kernels K(x, z) = (x T z + 1) p p is the degree of the polynomial and specified by the user. Radial basis function kernels ) x z 2 K(x, z) = exp ( 2σ 2 The width σ is specified by the user. This kernel corresponds to an infinite dimensional mapping φ. Sigmoid Kernel K(x, z) = tanh ( β 0 x T z + β 1 ) This kernel only meets Mercers condition for certain values of β 0 and β 1. Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 30 / 34

Advantages and disadvantages of SVM Advantages The problem doesn t have local minima and we can found its optimal solution in polynomial time. The solution is stable, repeatable, and sparse (it only involves the support vectors). The user must select a few parameters such as the penalty term C and the kernel function and its parameters. The algorithm provides a method to control complexity independently of dimensionality. SVMs have been shown (theoretically and empirically) to have excellent generalization capabilities. Disadvantages There is no method for choosing the kernel function and its parameters. It is not a straight forward method to extend SVM to multi-class classifiers. Predictions from a SVM are not probabilistic. It has high algorithmic complexity and needs extensive memory to be used in large-scale tasks. Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 31 / 34

Generalized linear classifier In nonlinear SVM, we saw that the mapping transformed the problem to a linearly separable one. Assume that feature vectors to be in the D dimensional space R D and they belong to either of the two classes C 1 and C 2, which are nonlinearly separable. Let f 1 (.), f 2 (.),..., f k (.) be nonlinear functions f i : R D R for i = 1, 2,..., k We define this mapping as f 1 (x) f 2 (x) y =. f k (x) The goal now is to investigate whether there is an appropriate value for k and functions f i so that classes C 1, C 2 are linearly separable in the k dimensional space of the vectors y. Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 32 / 34

Generalized linear classifier (cont.) We investigate whether there exists a k dimensional space where we can construct a hyperplane w R k so that w 0 + w T y > 0 if x C 1 w 0 + w T y < 0 if x C 2 If in the original space, two classes were separable by a (nonlinear) hypersurface g(x) = 0, then above relations are equivalent to approximating the nonlinear g(x) as a linear combination of f i (x), that is, g(x) = w 0 + k w i f i (x) Once the functions f i have been selected, the problem becomes a typical design of a linear classifier, that is, to estimate the weights w i in the k dimensional space. i=1 This justifies the term generalized linear classification. Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 33 / 34

Generalized linear classifier (cont.) The generalized linear classification can be shown as. This diagram corresponds to some previously studied models such as support vector models, linear regression, and neural networks. Although the model is similar to support vector machines, but the training phase is completely different. Hamid Beigy (Sharif University of Technology) Linear & nonlinear classifiers Fall 1394 34 / 34