support vector machines (svm) and kernel methods

20
A. Cornuéjols AgroParisTech – INRA MIA 518 Support Vector Machines (SVM) and kernel methods 2 / 78 Course « SVM and kernel methods » (A. Cornuéjols) Outline 1. Supervised inducHon: a reminder 2. Perceptron with widest margin: the SVM 1. DerivaHon 2. The margin: its significaHon ; its importance 3. SoP margins 3. SVM and the kernel trick 4. Kernels engineering 5. In pracHce 6. Conclusion 3 / 78 Course « SVM and kernel methods » (A. Cornuéjols) Supervised inducHon A reminder 4 / 78 Course « SVM and kernel methods » (A. Cornuéjols) Supervised Learning n Learning of a func%on Input -> Output (X Y) Predic%on • Stock exchange prices T • Predict when a mechanical piece will break down n • Weather structure T structure Classifica%on • Molecule {acHve, not acHve} • Microarray {cancer, not cancer} • Temporal series {normal, abnormal}

Upload: others

Post on 28-Mar-2022

9 views

Category:

Documents


0 download

TRANSCRIPT

Tr-SVM-english(2018)2 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
Outline
2. Perceptron with widest margin: the SVM
1. DerivaHon
3. SoP margins
4. Kernels engineering
5. In pracHce
Supervised inducHon
A reminder
Supervised Learning
n Learning of a func%on Input -> Output (X → Y)
– Predic%on
• Predict when a mechanical piece will break down ℜn → ℜ
•Weather structureT → structure
Machine Learning
6 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
Learning methods
n SVM
Fondamentalement
2. Le principe de minimisaHon du risque empirique est naïf
3. À remplacer par un principe de minimisa%on d’un risque régularisé
8 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
Le critère inducHf
n Critère de subs%tu%on à la place du risque réel
1. Risque empirique régularisé
2. Fonc%on de perte de subs%tu%on (surrogate funcHon)
3. Contrainte sur l’espace des hypothèses considéré H
9 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
Decision funcHons
n How to choose the relevant points?
n How to weight the points?
n Which distance to use?
+ + ++
+ ++
- -
-
- -
-
- -
-
Learning a decision boundary
!
!
"
"
!
!
"
"
!
!
"
"
The Perceptron
The perceptron: elementary algebra
n In the plan
The perceptron: elementary algebra
– Expression of an hypothesis (perceptron) :
15 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
How to choose the right perceptron?
Given a learning set, there exists a set of soluHons.
Here is one of them with the induced classificaHon of points.
16 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
Perceptron
Perceptron: why select the largest margin?
n Assume that the two target classes can be linearly separated.
– There generally exist an infinite number of soluHons
– We want to select the one that maximizes the distance to the nearest examples of the two classes: this is classifier with maximal margin
n IntuiHve jusHficaHon: it is the linear classifier that saHsfies the constraints set by the training instances and is the most robust to possible variaHons ofS.
18 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
SVM « Séparateurs à vastes marges »
n Vapnik (1992)
SVM « Séparateurs à vastes marges »
n We want:
n Decision rule:
n We decide on the following constraints (we are free to set our referenHal):
yi = +1 if xi is a `+’
yi = -1 if xi is a `-’
!
!
"
"
#
?
SVM « Séparateurs à vastes marges »
should be maximized
1 + w0
1 + w0
SVM: the linear case (primal expression)
– The normalized margin is equal to
– So that an equivalent problem is (primal expression):
n It is a quadra%c op%miza%on problem with linear constraints. There exists a whole set of efficient algorithms. One can thus obtain the soluHon vector w* plus wO* that define the decision func%on:
22 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
n An opHmizaHon problem has a dual form if the funcHon to be opHmized and the constraints are strictly convex. Then the soluHon of the dual form is also a soluHon of the primal form of the opHmizaHon problem.
n First define the Lagrangian
n The soluHon corresponds to a saddle point of the Lagrangian :
SVM: the linear case (the dual form)
23 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
n The Lagrangian
Representer theorem
SVM: the linear case (the dual form)
n In order to find the α coefficients, one must solve the quadraHc opHmizaHon problem:
25 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
n Under the Karush-Kuhn-Tucker condi%ons, only the points on the margin (hyperplanes) are involved.
n These points are known as support vectors
n So the soluHon can be sparse:
n And
26 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
SVM: the Gram matrix
SVM: the linear case (the dual form)
28 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
Analysis
n In a way, this is not different from a nearest neighbor classifier
– The relevant neighbors are the support vectors
– They are weighted with the αi coefficients
– The similarity func%on is given by the dot product
n The soluHon is enHrely determined by the Gram matrix
– Its characterisHcs tell a lot about the problem
n The soluHon h(x) is a linear combina%on
29 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
SoP-margin SVM
The perceptron: robustness
n But what if there is noise in the data or if outliers are present?
31 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
The perceptron: robustness
n Mais si il y a du bruit dans les données ou des points aberrants ?
32 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
The perceptron: robustness
n One is ready to tolerate violaHons of the constraints (up to a certain limit set by a constant C)
33 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
SVM with soP margins
n We are ready to tolerate viola%ons of the constraints set by the learning examples (up to a limit set by the constant C)
n « surrogate loss func>ons »
n The hinge lossis the most used
– For some good theoreHcal reasons
34 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
SVM : marges poreuses
SVM with soP margins
n Control of the bias-variance tradeoff
– C large: one is tolerant to errors • Low variance: less sensiHvity to variaHons of S • Stronger Bias : we want hypotheses with large margins
– C small: Errors are costly • Large variance: high sensiHvity to the characterisHcs of S •Weaker Biais: we are less demanding on the size of the margin
C controls this tradeoff • It is oPen set using cross-validaHon
36 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
SVM
From the linear to the non linear case
n Idea: to increase the dimension of the input space
n By genera%ng a whole lot of new dimensions
– That result from combinaHons and funcHons of the iniHal dimensions (descripHve features)
n And search a linear discriminant func%on in this redescrip%on space
38 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
Change of representaHon
n From the non linear to the linear case, thanks to …
39 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
Change of representaHon
40 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
Change of representaHon
φ
Change of representaHon
42 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
Change of representaHon
Change of representaHon
n We are looking for:
– A change of representaHon such that • A linear decision funcHon exists between the classes • Obeying the true « similarity » between the data points
n TranslaHon
– Find a redescripHon space φ(X) (feature expansion map) with (very) high dimension • But how to find φ(X) ? • Under the addiHonal constraint that computaHons are tractable?
44 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
QuesHons and the “kernel trick”
n Is it more likely that the training set be linearly separable when it is projected in a high dimensional space?
– Yes
– AutomaHcally
– Simple
n How to get tractable computa%ons in such a high dimensional space?
– Not even a problem
ProjecHon in a redescripHon space
46 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
SVM: the linear case (the dual form)
n In order to find the α coefficients, one must solve the quadraHc opHmizaHon problem:
47 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
SVM: the linear case in the feature space (the dual form)
n In order to find the α coefficients, one must solve the quadraHc opHmizaHon problem:
48 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
SVM: the linear case in the input space (the dual form)
n In order to find the α coefficients, one must solve the quadraHc opHmizaHon problem:
49 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
SVM: the gist
50 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
Change of representaHon and kernel funcHons
n The kernel func%on trick
m FuncHon k such that:
where: RedescripHon space with a dot product
51 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
Examples of kernel funcHons
n Rk: The space F defined by Φ is not unique! :
is a kernel funcHon
(the very same kernel funcHon corresponds also to the dot product in this other space as well)
52 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
IllustraHon
n Given 5 points on the line: {(x1=1, u1 =1), (x2=2, u2= 2), (x3= 4, u3= -1), (x4= 5, u4 = -1), (x5= 6, u5= 1)}
m Let us use a polynomial kernel of degree 2
k(xi, xj) = (xi xj + 1)2
C = 100
1 2 4 5 6
53 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
IllustraHon
n An algorithm that solves quadraHc opHmizaHon problems will find
α1 = 0, α2 = 2.5, α3 = 0, α4 = 7.333, α5 = 4.833
– The support vectors are: { x2 = 2, x4 = 5, x5 = 6}
n Giving the decision func>on:
– h(x) = (2.5)(1)(2x+1)2 + 7.333(1)(5x+1)2 + 4.833(1)(6x+1)2+b = 0.6667 x2 - 5.333 x + b
– With b obtained thanks to h(2)=1 or to h(5)=-1 or to h(6)=1, since x2, x4 and x5 are on the line ui(wTΦ(x)+b) = 1 which gives b = 9
n Hence: h(x) = 0.6667 x2 - 5.333 x + 9
54 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
IllustraHon
classe 2 classe 1 classe 1
{x = 2, x = 5, x = 6} are the support vectors
55 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
SVM: the linear case (the dual form)
56 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
Wri~en digits recogniHon
Support vectors, examples
I Show that the Leave-One-Out error is less than # sv.
LOO: iteratively, learn on all examples but one, and test on the remaining
one
Another perspecHve
58 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
Kernel methods
59 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
SVM et méthodes à noyaux
60 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
Kernel methods
m Polynomial kernels
All products of at most d variables
m Gaussian kernels
m Sigmoïd “kernel”
used in neural networks
Radius-Basis funcHon kernel (RBF)
K (x, x) = exp ||x x||2

For x in IR

I Choice of ? (intuition: think of H, Hi ,j = yiyjK (xi , xj))
Example, Radius-Based Function kernel (RBF)
K (x, x) = exp ||x x||2

For x in IR

I Choice of ? (intuition: think of H, Hi ,j = yiyjK (xi , xj))
62 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
In pracHce
In pracHce
• Its form
• Its parameters
n SelecHng these (meta) parameters is usually done using cross-validaHon
64 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
Example
: example +
• : example -
Démo :
http://svm.research.bell-labs.com/
http://svm.dcs.rhbnc.ac.uk/pagesnew/GPat.shtml
A learning set
Impact of the control parameters
n Learning two classes
n SVM à Gaussian kernels
n Here two values of s are tested
– Top : a small value
– BoXom : a large value
– There are more support vectors at the top
than at the boXom
2σ 2
Control parameters: the kernel funcHon
n http://svm.dcs.rhbnc.ac.uk/pagesnew/GPat.shtml
n Support vectors: 4 + et 3 –
n A polynomial kernel of degree 5 and C = 10000 68 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
Control parameters: the kernel funcHon
n 47 examples (22 +, 25 -)
n Support vectors: 4 + et 3 - Polynomial kernels of degree 2, 5 or 8 and C = 10000
Gaussian kernel with σ = 2, 5, 10 or C = 10000
(4-, 5+) (8-, 6+) (10-, 11+)
(5-, 4+) (3-, 4+) (5-, 4+)
69 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
Adding a few points ...
m Polynomial kernel of degréee 5 and C = 10000
70 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
EsHmaHon of the performance
n Empirically: using cross-validaHon
– Number of support vectors
– Characteris%cs of the Gram matrix G
• If there is no structure in G, no regulariHes can be found in the data
• E.g. – If terms off-diagonal are very small: over-fiUng
– If the matrix is uniform: under-fiUng (all points are labeled in the
same class)
Kernel funcHons Engineering
Kernel funcHons exist for non vectorial spaces
n Genomes
n Texts
n Images
n Video
Les méthodes à noyau
m Noyaux polynomiaux
Tous les produits d’au plus d variables
m Noyaux gaussiens
m Noyaux sigmoïdes
proche des réseaux connexionnistes
ConstrucHng kernel funcHons
Assessment
Conclusions
– Introduces the margin as a measure of “capacity”
– The kernel trick opens non linear problems to well controlled
linear methods thanks to virtual redescripHons
77 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
Conclusions
n Quite a black box
– It is very difficult to interpret what has been learned (support vectors (and their weights) in a unknown feature space)
– A priori knowledge can only be expressed through the choice of the kernel funcHon
n Not well adapted to problem exhibiHng “long distance” dependencies
– Only one level of non lineariHes (vs. “deep belief networks”)
n Current research
– Learning kernels
– Combining kernels
– Favoring sparse soluHons (e.g. LASSO) 78 / 78 Course « SVM and kernel methods » (A. Cornuéjols)
References
A. Cornuéjols & L. Miclet ApprenHssage ArHficiel. Concepts et algorithmes Eyrolles (2° éd.), 2010
Lutz Hamel Knowledge discovery with Support Vector Machines Wiley, 2009
J. Shawe-Taylor & N. CrisHanini Kernel methods for pa~ern analysis Cambridge University Press, 2004
B. Schölkopf & A. Smola Learning with kernels. Support Vector Machines, RegularizaHon, OpHmizaHon, and Beyond MIT Press, 2002