Try   HackMD

Lien de la note Hackmd

On a un probleme de classification binaire:

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Probleme: donnees d'apprentissage

{(xi,yi)}i=1nxiRpyi{1,+1}

On cherche un hyperplan de

Rp qui separe parfaitement les deux classes

Dans notre exemple, il n'y a pas qu'un seul hyperplan separant les 2 classes:

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Hyperplan

Hyperplan: caracterise par un vecteur normal

wRp et un offset
bR

xHwTx+b=0

Lequel des hyperplans semble meilleur ?

Celui du milieu

On a une infinite de solutions possibles (meme risque empirique), mais toutes les solutions n'ont pas les memes performances en generalisation

Geometriquement, on veut celui qui est le plus loin des points (aka la marge de l'hyperplan)

On cherche

(w,b)Rp×R tel que tous les echantillons de la classe
1/+1
soient dans le demi espace:

  • positif:
    wTxi+b0
    yi=+1
  • negatif:
    wTxi+b0
    yi=1

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Dans tous les cas:

xiRp,yi(wTxi+b)0

Marge

Marge: distance de l'hyperplan aux echantillons les plus proches

MH=mini=1,,n{d(xi,H)}=mini=1,,n{d(xi,x),xRn,wTx+b=0}=d(xs,H)avec xs vecteur de support

On va chercher l'hyperplan qui maximise la marge

H=argmax(w,b)Rp×RMH=d(xs,H)

Distance d'un point

x0 a un hyperplan:

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

d(x0,H)=yx0

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

(L)={x0+tw,tR}

y(L),tR,y=x0+twy(H)wTy+b=0wT(x0+tw)+b=0wTx0+twTww2+b=0t=1w|2(wTx0+b)

d(x0,H)=yx0=x0+twx0=tw=|t|w=|1w2(wTx0+b)|×wd(x0,H)=|wTx0+bw

MH=mini{d(xi,H)}=mini{|wTxi+b|w}=1wmini{|wTxi+b|}=|wTxs+b|wxs vecteur de support

On cherche

argmax(w,b)MH=argmax(w,b)|wTxs+b|w

Si

(w,b) est une solution,
(kw,kb)
k>0
est aussi solution.

On va choisir

(w,b) tels que
|wTxs+b|=1

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Marge normalisee:

1w

SVM

On cherche a:

maximiser1wmaximiser2wminimiser12w2

SVM:

argmin(w,b)Rd×R12w2tel que yi(wTxi+b)1i=1,,n

12w2=12wTwyi(wTxi+b)11yi(wTxi+b)0i

Le Lagrangien de (SVM) est:

L(w,b,λ)=12wTw+i=1nλi(1yi(wTxi+b))wRp,bR,λRn=12wTwi=1nλi(yi(wTxi+b)1)

Conditions KKT

Stationnarite du Lagrangien

wL(w,b,λ)=0=w(12wTw)wi=1nw(λi(yi(wTλiyixixi+b)1))0=wi=1nλiyixiw=i=1nλiyixiw est une combinaison lineaire des xibL(w,b,λ)=0=i=1nλiyi

A chaque

xi correspond un
λi

  • λi0λi
    est la "force" avec laquelle
    xi
    repousse l'hyperplan
  • i=1nλiyi=0
    l'hyperplan est a l'equilibre

Complementarite

i=1,,nλi(1yi(wTxi+b))=0(αigi(x)=0i)

Soit

λi=0:

1yi(wTxi+b)<0yi(wTxi+bxi n'est pasun vecteurde support)>1λi=0{xi ne repousse pas l'hyperbolene contribue pas a la solution w=i=1nλiyixila solution ne change pas si on enleve xi du jeu de donnees

Soit

λi>0:

1yi(wTxi+b)=0yi(wTxi+bxi est un vecteurde support)=1λi>0{la solution change si on enleve xi du jeu de donnees

Recap

w=i=1nλiyixio=i=1nλiyiL(w,b,λ)=12wTwi=1nλi(yi(wTxi+b)1)wTw=(i=1nλiyixi)T(j=1nλjyjxj)=i=1nλiyi(xi)Tj=1nλjyjxj=ijλiλjyiyjxiTxj

i=1nλi(yi(wTxi+b)1)=i=1nλiyiwTxi+bi=1nλiyii=1nλiiλiyi(j=1nλjyjxj)Txi=ijλiλjyiyjxiTxj

Probleme dual du SVM

maxλi0i=1nλiyiL=12i=1nj=1nλiλjyiyjxiTxj+i=1nλi

Sous reserve qu'on puisse resoudre le dual:

  • On trouve
    λi\*
  • On trouve
    w\*=i=1nλi\*yixi
  • On trouve
    b\*
    grace aux vecteurs de support
    yi(w\*txi+b\*)=1

Probleme dual du SVM se resout par Sequential Minimal Optimization
Pour resoudre