• Objectif
• d ´eterminer directement les fonctions discriminantes
• lin ´eaires: g ( x ) = w
0+ ∑
di=1
w
ix
i= w
tx + w
0• lin ´eaires g ´en ´eralis ´ees: g ( x ) =
d
∑
i=1a
iy
i( x ) = a
ty
• en minimisant le risque empirique
Fonctions discriminantes lin ´eaires
2• Justifications
• parfois optimal
• facile `a calculer
• candidates pour des classifieurs initiales
• aborder quelques principes importants
• fonction de d ´ecision:
f ( x ) =
C
1si g ( x ) > 0 , C
2si g ( x ) < 0 =
C
1si w
tx > − w
0, C
2si w
tx < − w
0x0=1
x1
. . .
w2 w0
w1
wd
g(x)
x2
. . .
xdunit´e de biais unit´e de sortie
unit´es d’entr´ee
Fonctions discriminantes lin ´eaires
4• G ´eom ´etrie – deux classes
• fronti `ere de d ´ecision H est un hyperplan:g ( x ) = 0
• x
1, x
2∈ H: w
t( x
1− x
2) = 0
• r ´egions de d ´ecision: R
1:cot ´e positif, R
2:cot ´e n ´egatif
• r = distance alg ´ebrique de x et H:
x = x
p+ r w w
g ( x ) = w
tx + w
0= r w r = g ( x )
w
• G ´eom ´etrie – deux classes
x
g( x ) = 0 w
x
1x
2x
3w
0/ || w ||
r
H
x
pR
1R
2Fonctions discriminantes lin ´eaires
6• G ´eom ´etrie – multiclasses
• C
i/ non C
iω
1not ω1
ω1
not ω2
ω2
not ω3 ω3
not ω4
ω4
ω
2ω
4ω
3r´egion ambigue
• G ´eom ´etrie – multiclasses
• N ( N − 1 )/ 2 fonctions discriminantes
ω1
ω1
ω1
ω2
ω2
ω2
ω3
ω3
ω3
ω4
ω4 ω4
ω
3ω
2ω
1ω
4H13
H12
H14
H23 H24
H34
r´egion ambigue
Fonctions discriminantes lin ´eaires
8• Fonctions discriminantes lin ´eaires
• machine lin ´eaire: g
j( x ) = w
tjx + w
j0, j = 1 ,..., N
• fronti `eres de d ´ecision H
i,j:g
i( x ) = g
j( x )
• ( w
i− w
j) est orthogonal `a H
i,j• r ( x , H
i,j) = g
i( x ) − g
j( x )
w
i− w
j• Fonctions discriminantes lin ´eaires
R
1R
2R
3R
4R
5ω
1R
2R
3R
1ω
2ω
1ω
3ω
5ω
2ω
3ω
4H
15H
25H
24H
14H
35H
13H
34H
23H
12H
23H
13Fonctions discriminantes lin ´eaires
10• Fonctions discriminantes lin ´eaires g ´en ´eralis ´ees:
g ( x ) =
d i ∑ = 1
a i y i ( x ) = a t y
• exemple: fonction discriminante quadratique:
g ( x ) = w
0+ ∑
di=1
w
ix
i+ ∑
di=1 d
∑
j=1w
i jx
ix
j• fronti `ere de d ´ecision: hyperquadrique
• Fonctions discriminantes lin ´eaires g ´en ´eralis ´ees
• exemple: g ( x ) = a
1+ a
2x + a
3x
2, y =
1 x x
2
0
-1 0
1 2
y2
0 2 4
y3
0.5 1
1.5 2
2.5
y1
1
-1 0 2
-2 x
R1
R1 R2
y = 1
( )
xx2R2
R1
ˆ
ˆ
12
• exemple: y =
x
1x
2α x
1x
2
y
2w
R
2R
1R
1R
2R
1x
1x
2x
1x
2y
1y
3y = x ( )1x α
2x
1x
2 H ˆ
ˆ
ˆ
• Vecteur augment ´e
• g ( x ) = w
0+ ∑
di=1
w
ix
i= ∑
di=0
w
ix
i( x
0= 1 )
• g ( x ) =
d i
∑
=1a
iy
i, d = d + 1, y =
1 x
1...
x
d
, a =
w
0w
1...
w
d
=
w
0w
Fonctions discriminantes lin ´eaires
14• Vecteur augment ´e
y1
y2
y0
a
y0=1
R1
R2
y0=0
y=01
y2=0
fronti
`ere de d´ecision
• S ´eparabilit ´e lin ´eaire
• D
n= ( y
1, z
1),..., ( y
n, z
n)
, z
i=
1 si y
iest classifi ´e C
1− 1 si y
iest classifi ´e C
2• g ( x ) = a
ty s ´epare D
nsans erreur:
a
ty
iz
i> 0 , i = 1 ,..., n
• a: vecteur s ´eparateur, vecteur de solution
Fonctions discriminantes lin ´eaires
16• S ´eparabilit ´e lin ´eaire
y
1y
2y
1y
2a a
r´egion de r´egion de
solution solution
plans´eparateur
plan”s´eparateur”
• Marge de s ´eparation:
m i = g ( x i ) z i = a t yz i
• S ´eparation avec une marge b:
m i = a t y i z i > b , i = 1 ,..., n
Fonctions discriminantes lin ´eaires
18• Marge de s ´eparation
y
1y
2y
3a
1a
2a
2a
1y
1y
2y
3b/ || y
2
||
b/ || y
1||
b/ || y ||
3}
}
}
r´egion de r´egion de
solution solution
• Proc ´edures de descente de gradient
• fonction de crit `ere: J ( a ) – minimis ´ee si a est une solution
• a ( k + 1 ) = a ( k ) − η( k ) J ( a ( k ))
• η( k ) : taux d’apprentissage
D ESCENTE D E G RADIENT S IMPLE ( Θ , η (·), a
0)
1 a ← a
02 k ← 0 3 faire
4 k ← k + 1
5 a ← a − η( k ) J ( a )
6 jusqu’ `a | η ( k ) J ( a )| < Θ
7 retourner a
Fonctions discriminantes lin ´eaires
20• Descente de Newton
• J ( a ) J ( a ( k )) + J
t( a − a ( k )) + 1
2 ( a − a ( k ))
tH ( a − a ( k ))
• matrice hessienne: H
i j= δ
2J δ a
iδ a
j• a ( k + 1 ) = a ( k ) − H
−1J
D ESCENTE D E N EWTON (Θ, a
0)
1 a ← a
02 faire
3 a ← a − H
−1J ( a )
4 jusqu’ `a | H
−1J ( a )| < Θ
5 retourner a
• Descente de Newton
a
1a
2J(a)
Fonctions discriminantes lin ´eaires
22• Le perceptron
• J
p( a ) = ∑
ni=1
I
{atyizi≤0}(− a
ty
iz
i)
• J
p= ∑
ni=1
I
{atyizi≤0}(− y
iz
i)
• a ( k + 1 ) = a ( k ) + η( k ) ∑
ni=1I
{atyizi≤0}y
iz
i• Le perceptron
P ERCEPTRON B ATCH ( Θ , η (·), a
0)
1 a ← a
02 k ← 0 3 faire
4 k ← k + 1
5 a ← a + η( k ) ∑
ni=1I
{atyizi≤0}y
iz
i6 jusqu’ `a | η ( k ) ∑
ni=1I
{atyizi≤0}y
iz
i| < Θ
7 retourner a
Fonctions discriminantes lin ´eaires
24• Fonctions de crit `ere
-2 0 2
4 -2
0 2
4 0
100
-2 0 2
4 -2
0 2
4 0
5 -2 0 2 4 -2
0 2
4 0
1 2 3
-2 0 2 4 -2
0 2
4 0
5 10
y1 y1
y1 y1
y2 y2
y2 y2
y3 y3
y3 y3
a2 a2
a2 a2
a1 a1
a1 a1
Jp(a)
Jq(a) Jr(a)
J(a)
r´egion de r´egion de
r´egion de r´egion de
solution solution
solution solution
1 a ← a
02 k ← 0 3 faire
4 k ← ( k + 1 ) mod n
5 si a
ty
kz
k≤ 0 alors y
kmal classifi´e 6 a ← a + y
kz
k7 jusqu’ `a ∑
ni=1I
{atyizi≤0}= 0 pas d’erreur 8 retourner a
• Th ´eor `eme
• Si l’ensemble d’entraˆınement est lin ´eairement s ´eparable, l’algorithm
P ERCEPTRON E N L IGNE se termine `a une vecteur de solution apr `es
un nombre fini de corrections.
Fonctions discriminantes lin ´eaires
26• Le perceptron en-ligne, avec marge, d’incr ´ement variable
P ERCEPTRON E N L IGNE M ARGE V ARIABLE (η(·), a
0, b)
1 a ← a
02 k ← 0 3 faire
4 k ← k + 1 5 k
← k mod n
6 si a
ty
kz
k≤ b alors 7 a ← a + η( k ) y
kz
k8 jusqu’ `a ∑
ni=1I
{atyizi≤b}= 0 pas d’erreur par rapport `a la marge b
9 retourner a
• Conditions de convergence
• η( k ) ≥ 0
• lim
m→∞
m k
∑
=1η( k ) = ∞
• lim
m→∞
∑
mk=1η
2( k )
(∑
mk=1η ( k ))
2= 0
Fonctions discriminantes lin ´eaires
28• Le perceptron batch d’incr ´ement variable
• y
(k)= ∑
ni=1
I
{at(k)yizi≤0}y
iz
iP ERCEPTRON B ATCH V ARIABLE (η(·), a
0)
1 a ← a
02 k ← 0 3 faire
4 k ← k + 1
5 a ← a + η( k ) ∑
ni=1I
{atyizi≤0}y
iz
i6 jusqu’ `a ∑
ni=1I
{atyizi≤0}= 0
7 retourner a
• Proc ´edures de relaxation
• J
q( a ) = ∑
ni=1
I
{atyizi≤0}( a
ty
iz
i)
2• J
r( a ) = 1 2
n i
∑
=1I
{atyizi≤b}( a
ty
iz
i− b )
2y
iz
i2
• J
r= ∑
ni=1
I
{atyizi≤b}a
ty
iz
i− b y
iz
i2
y
iz
i• a ( k + 1 ) = a ( k ) + η( k ) ∑
ni=1
I
{atyizi≤b}b − a
ty
iz
iy
iz
i2
y
iz
iFonctions discriminantes lin ´eaires
30• Proc ´edures de relaxation
R ELAXATION B ATCH M ARGE ( η (·), a
0, b)
1 a ← a
02 k ← 0 3 faire
4 k ← k + 1
5 a ← a + η( k ) ∑
ni=1I
{atyizi≤b}b−atyiziyizi2
y
iz
i6 jusqu’ `a ∑
ni=1I
{atyizi≤b}= 0
7 retourner a
• Relaxation en-ligne
R ELAXATION E N L IGNE M ARGE (η(·), a
0, b)
1 a ← a
02 k ← 0 3 faire
4 k ← k + 1 5 k
← k mod n
6 si a
ty
kz
k≤ b alors
7 a ← a + η( k )
b−yatykzkkzk2
y
kz
k8 jusqu’ `a ∑
ni=1I
{atyizi≤b}= 0
9 retourner a
Fonctions discriminantes lin ´eaires
32• Relaxation en-ligne
• r ( k ) = b − a
ty
kz
ky
kz
ka
ty
k= b
a (k)
y
kr(k)
y
1y
21- η η
• η > 1: sur-relaxation
• η < 1: sous-relaxation
• condition de convergence: 0 < η < 2
a1 a1
J(a) J(a)
Fonctions discriminantes lin ´eaires
34• Comportement dans le cas non-s ´eparable
• proc ´edures de correction d’erreur
• fonctionnent bien si
• la d ´ecision de Bayes est `a peu pr`es lin ´eaire
• l’erreur de Bayes est petite
• si 2 d > n, la probabilit ´e de non-s ´eparabilit ´e est petite
• Incr ´ement fixe
• boucle infinie
• engendre un proc ´essus d’ ´etat fini
• moyenner les vecteurs de poids
• Incr ´ement variable
• converge si η( k ) → 0
Fonctions discriminantes lin ´eaires
36• L’approche d’erreur carr ´ee (r ´egression)
• soit b = ( z
1,..., z
n)
t• Id ´ealement on voudrait trouver a tel que Ya = b
• Mais on commet des erreurs e = Ya − b
• J
s( a ) = Ya − b
2= ∑
ni=1
( a
ty
i− b
i)
2• J
s( a ) = ∑
ni=1
2 ( a
ty
i− b
i) y
i= 2Y
t( Ya − b )
• Y
tYa = Y
tb
• a = ( Y
tY )
−1Y
tb = Y
†b
Fonctions discriminantes lin ´eaires
38• Proc ´edure de Widrow-Hoff (LMS)
• batch: a ( k + 1 ) = a ( k ) + η( k ) Y
t( b − Ya ( k ))
• en ligne: a ( k + 1 ) = a ( k ) + η( k ) y
k( b
k− a
ty
k) LMS ( Θ , η (·), a
0)
1 a ← a
02 k ← 0 3 faire
4 k ← k + 1 5 k
← k mod n
6 a ← a + η( k ) y
k( b
k− a
ty
k)
7 jusqu’ `a | η ( k ) y
k( b
k− a
ty
k)| < Θ
8 retourner a
• Proc ´edure de Widrow-Hoff (LMS)
• se comporte bien dans le cas non-s ´eparable
• ne converge pas n ´ecessairement `a un hyperplan s ´eparateur dans les
cas s ´eparables
Fonctions discriminantes lin ´eaires
40• La machine de support vector (SVM)
• objectif: trouver un hyperplan s ´eparateur avec une grande marge z
ig ( y
i) = z
ia
ty
i• maximiser b: z
ig ( y
i)
a ≥ b i = 1 ,..., n
y1 y2
R2
R1
hyperplan
optimal
mar gemar
ge
maximale maximale