Blame

d5b8b5 lugonthier 2026-07-01 14:24:01
Refactor section headings for consistency and clarity across multiple documents in the Machine Learning module. Updated headings to include numerical prefixes for better organization and navigation. Adjusted content formatting and improved terminology in French translations for decision trees, ensemble methods, and other foundational concepts.
1
# 4. Machines à vecteurs de support
1c3139 Lucas Gonthier 2026-06-30 12:04:21
Initial commit: course content (Machine Learning, MLOps) in EN and FR Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2
3
Les machines à vecteurs de support sont des classifieurs linéaires à grande marge. Elles
4
choisissent la frontière qui maximise la distance aux points les plus proches, contrôlent le
5
surapprentissage avec la perte charnière et une pénalité $C$, et utilisent des noyaux pour
6
ajuster des frontières non linéaires sans jamais former l'application de caractéristiques. Partout,
7
les étiquettes valent $y \in \{-1,+1\}$ et la décision utilise un score brut $z = w^T x - b$.
8
9
**Objectifs**
10
- Définir l'hypothèse SVM, son hyperplan séparateur et la marge géométrique.
11
- Formuler le primal à marge dure et le primal à marge souple avec perte charnière et pénalité $C$.
12
- Définir les noyaux, l'astuce du noyau et la condition de Mercer.
13
- Former le lagrangien, dériver le dual et les conditions KKT, et définir les vecteurs de support.
14
d5b8b5 lugonthier 2026-07-01 14:24:01
Refactor section headings for consistency and clarity across multiple documents in the Machine Learning module. Updated headings to include numerical prefixes for better organization and navigation. Adjusted content formatting and improved terminology in French translations for decision trees, ensemble methods, and other foundational concepts.
15
## 4.1 Classifieur à marge optimale
1c3139 Lucas Gonthier 2026-06-30 12:04:21
Initial commit: course content (Machine Learning, MLOps) in EN and FR Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
16
17
Les étiquettes valent $y \in \{-1,+1\}$, avec un vecteur de poids $w \in \mathbb{R}^{n}$ et un biais $b$.
18
d5b8b5 lugonthier 2026-07-01 14:24:01
Refactor section headings for consistency and clarity across multiple documents in the Machine Learning module. Updated headings to include numerical prefixes for better organization and navigation. Adjusted content formatting and improved terminology in French translations for decision trees, ensemble methods, and other foundational concepts.
19
### 4.1.1 Hypothèse et frontière
1c3139 Lucas Gonthier 2026-06-30 12:04:21
Initial commit: course content (Machine Learning, MLOps) in EN and FR Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
20
21
L'hypothèse est définie comme le signe du score brut $z = w^T x - b$ :
22
23
$$\boxed{ h(x) = \operatorname{sign}(w^T x - b) }$$
24
25
La frontière de décision est l'ensemble des points de score nul :
26
27
$$\boxed{ w^T x - b = 0 }$$
28
29
*Remarque :* $w$ est orthogonal à la frontière, il en fixe donc l'orientation, et $b$ fixe le décalage.
30
d5b8b5 lugonthier 2026-07-01 14:24:01
Refactor section headings for consistency and clarity across multiple documents in the Machine Learning module. Updated headings to include numerical prefixes for better organization and navigation. Adjusted content formatting and improved terminology in French translations for decision trees, ensemble methods, and other foundational concepts.
31
### 4.1.2 Marge géométrique
1c3139 Lucas Gonthier 2026-06-30 12:04:21
Initial commit: course content (Machine Learning, MLOps) in EN and FR Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
32
33
La marge géométrique de l'exemple $i$ est définie comme sa distance signée à la frontière, rendue
34
positive par l'étiquette :
35
36
$$\boxed{ \gamma^{(i)} = y^{(i)} \, \frac{w^T x^{(i)} - b}{\lVert w \rVert} }$$
37
38
Un point correctement classé vérifie $\gamma^{(i)} > 0$. La marge du jeu de données est la plus
39
petite $\gamma^{(i)}$ sur tous les exemples.
40
41
*Remarque :* diviser par $\lVert w \rVert$ rend la marge invariante au rééchelonnement de $(w,b)$,
42
contrairement au score brut $z$.
43
d5b8b5 lugonthier 2026-07-01 14:24:01
Refactor section headings for consistency and clarity across multiple documents in the Machine Learning module. Updated headings to include numerical prefixes for better organization and navigation. Adjusted content formatting and improved terminology in French translations for decision trees, ensemble methods, and other foundational concepts.
44
### 4.1.3 Primal à marge dure
1c3139 Lucas Gonthier 2026-06-30 12:04:21
Initial commit: course content (Machine Learning, MLOps) in EN and FR Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
45
46
En fixant l'échelle pour que les points les plus proches vérifient $y^{(i)}(w^T x^{(i)} - b) = 1$,
47
maximiser la marge équivaut à minimiser $\lVert w \rVert^2$ sous une marge fonctionnelle unitaire :
48
49
$$\boxed{ \min_{w,b} \tfrac{1}{2}\lVert w \rVert^2 \quad \text{s.c.} \quad y^{(i)}(w^T x^{(i)} - b) \ge 1 \ \ \forall i }$$
50
51
C'est un programme quadratique convexe à contraintes linéaires, il admet donc un optimum unique.
52
53
*Remarque :* il exige des données linéairement séparables. La leçon suivante assouplit cela avec
54
des variables d'écart.
55
56
![Marge SVM et vecteurs de support](/fr/Machine%20Learning/04%20Support%20Vector%20Machines/a/svm-margin.png)
57
58
*L'hyperplan optimal (trait plein) maximise la marge (pointillés). Les points entourés sont les vecteurs de support.*
59
d5b8b5 lugonthier 2026-07-01 14:24:01
Refactor section headings for consistency and clarity across multiple documents in the Machine Learning module. Updated headings to include numerical prefixes for better organization and navigation. Adjusted content formatting and improved terminology in French translations for decision trees, ensemble methods, and other foundational concepts.
60
## 4.2 Perte charnière
1c3139 Lucas Gonthier 2026-06-30 12:04:21
Initial commit: course content (Machine Learning, MLOps) in EN and FR Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
61
62
Le score brut est $z = w^T x - b$ et les étiquettes valent $y \in \{-1,+1\}$.
63
d5b8b5 lugonthier 2026-07-01 14:24:01
Refactor section headings for consistency and clarity across multiple documents in the Machine Learning module. Updated headings to include numerical prefixes for better organization and navigation. Adjusted content formatting and improved terminology in French translations for decision trees, ensemble methods, and other foundational concepts.
64
### 4.2.1 Perte charnière
1c3139 Lucas Gonthier 2026-06-30 12:04:21
Initial commit: course content (Machine Learning, MLOps) in EN and FR Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
65
66
La perte charnière est définie comme l'écart par lequel la marge $yz$ tombe sous $1$, tronqué à zéro :
67
68
$$\boxed{ L(z,y) = \max(0,\, 1 - yz), \quad z = w^T x - b }$$
69
70
Elle est nulle dès que $yz \ge 1$ (le point est correct et au-delà de la marge) et croît
71
linéairement à l'intérieur ou au-delà de la marge.
72
73
*Remarque :* la perte charnière est convexe mais non dérivable en $yz = 1$, on l'optimise donc
74
avec des sous-gradients.
75
d5b8b5 lugonthier 2026-07-01 14:24:01
Refactor section headings for consistency and clarity across multiple documents in the Machine Learning module. Updated headings to include numerical prefixes for better organization and navigation. Adjusted content formatting and improved terminology in French translations for decision trees, ensemble methods, and other foundational concepts.
76
### 4.2.2 Primal à marge souple
1c3139 Lucas Gonthier 2026-06-30 12:04:21
Initial commit: course content (Machine Learning, MLOps) in EN and FR Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
77
78
On introduit un écart $\xi_i \ge 0$ par exemple pour autoriser les violations de marge, pénalisé
79
par $C > 0$ :
80
81
$$\boxed{ \min_{w,b,\xi} \tfrac{1}{2}\lVert w \rVert^2 + C\sum_{i=1}^{m}\xi_i \quad \text{s.c.} \quad y^{(i)}(w^T x^{(i)} - b) \ge 1 - \xi_i, \ \ \xi_i \ge 0 }$$
82
83
À l'optimum $\xi_i = \max(0,\, 1 - y^{(i)}(w^T x^{(i)} - b))$, donc éliminer les écarts donne la
84
forme régularisée sans contrainte :
85
86
$$\boxed{ \min_{w,b} \tfrac{1}{2}\lVert w \rVert^2 + C\sum_{i=1}^{m}\max\!\big(0,\, 1 - y^{(i)}(w^T x^{(i)} - b)\big) }$$
87
88
C'est de la régularisation plus une perte charnière : le terme $\tfrac{1}{2}\lVert w \rVert^2$
89
élargit la marge et la somme pénalise les violations.
90
d5b8b5 lugonthier 2026-07-01 14:24:01
Refactor section headings for consistency and clarity across multiple documents in the Machine Learning module. Updated headings to include numerical prefixes for better organization and navigation. Adjusted content formatting and improved terminology in French translations for decision trees, ensemble methods, and other foundational concepts.
91
### 4.2.3 Rôle de $C$
1c3139 Lucas Gonthier 2026-06-30 12:04:21
Initial commit: course content (Machine Learning, MLOps) in EN and FR Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
92
93
| $C$ | Pénalité des violations | Marge | Comportement |
94
| --- | --- | --- | --- |
95
| petit | faible | large | plus de violations tolérées, variance plus faible |
96
| grand | forte | étroite | moins de violations, ajuste davantage les données |
97
98
*Remarque :* quand $C \to \infty$ aucune violation n'est tolérée, ce qui redonne le classifieur à
99
marge dure.
100
d5b8b5 lugonthier 2026-07-01 14:24:01
Refactor section headings for consistency and clarity across multiple documents in the Machine Learning module. Updated headings to include numerical prefixes for better organization and navigation. Adjusted content formatting and improved terminology in French translations for decision trees, ensemble methods, and other foundational concepts.
101
## 4.3 Noyaux
1c3139 Lucas Gonthier 2026-06-30 12:04:21
Initial commit: course content (Machine Learning, MLOps) in EN and FR Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
102
d5b8b5 lugonthier 2026-07-01 14:24:01
Refactor section headings for consistency and clarity across multiple documents in the Machine Learning module. Updated headings to include numerical prefixes for better organization and navigation. Adjusted content formatting and improved terminology in French translations for decision trees, ensemble methods, and other foundational concepts.
103
### 4.3.1 Définition d'un noyau
1c3139 Lucas Gonthier 2026-06-30 12:04:21
Initial commit: course content (Machine Learning, MLOps) in EN and FR Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
104
105
Un noyau est défini comme le produit scalaire d'une application de caractéristiques $\phi$
106
appliquée à deux entrées :
107
108
$$\boxed{ K(x,z) = \phi(x)^T \phi(z) }$$
109
110
Un noyau valide calcule ce produit scalaire directement, donc $\phi$ n'a jamais à être formée
111
(elle peut même être de dimension infinie).
112
d5b8b5 lugonthier 2026-07-01 14:24:01
Refactor section headings for consistency and clarity across multiple documents in the Machine Learning module. Updated headings to include numerical prefixes for better organization and navigation. Adjusted content formatting and improved terminology in French translations for decision trees, ensemble methods, and other foundational concepts.
113
### 4.3.2 Astuce du noyau
1c3139 Lucas Gonthier 2026-06-30 12:04:21
Initial commit: course content (Machine Learning, MLOps) in EN and FR Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
114
115
Le dual du SVM ne dépend des données qu'à travers des produits scalaires
116
$\langle x^{(i)}, x^{(j)} \rangle$. L'astuce du noyau remplace chaque produit scalaire par un noyau :
117
118
$$\boxed{ \langle x^{(i)}, x^{(j)} \rangle \ \longrightarrow \ K(x^{(i)}, x^{(j)}) }$$
119
120
Cela ajuste une frontière linéaire dans l'espace de caractéristiques, donc non linéaire dans
121
l'espace d'origine, au prix d'évaluer $K$ au lieu de $\phi$.
122
123
Un choix très répandu est le noyau gaussien (RBF) :
124
125
$$\boxed{ K(x,z) = \exp\!\left( -\frac{\lVert x - z \rVert^2}{2\sigma^2} \right) }$$
126
d5b8b5 lugonthier 2026-07-01 14:24:01
Refactor section headings for consistency and clarity across multiple documents in the Machine Learning module. Updated headings to include numerical prefixes for better organization and navigation. Adjusted content formatting and improved terminology in French translations for decision trees, ensemble methods, and other foundational concepts.
127
### 4.3.3 Condition de Mercer
1c3139 Lucas Gonthier 2026-06-30 12:04:21
Initial commit: course content (Machine Learning, MLOps) in EN and FR Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
128
129
Une fonction $K$ est un noyau valide si et seulement si, pour tout échantillon fini, sa matrice de
130
Gram est symétrique semi-définie positive :
131
132
$$\boxed{ K = K^T, \qquad K \succeq 0 }$$
133
134
*Remarque :* c'est la condition de Mercer. Elle garantit l'existence d'une application $\phi$, donc
135
le dual reste convexe.
136
d5b8b5 lugonthier 2026-07-01 14:24:01
Refactor section headings for consistency and clarity across multiple documents in the Machine Learning module. Updated headings to include numerical prefixes for better organization and navigation. Adjusted content formatting and improved terminology in French translations for decision trees, ensemble methods, and other foundational concepts.
137
### 4.3.4 Noyaux usuels
1c3139 Lucas Gonthier 2026-06-30 12:04:21
Initial commit: course content (Machine Learning, MLOps) in EN and FR Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
138
139
| Noyau | $K(x,z)$ | Note |
140
| --- | --- | --- |
141
| Linéaire | $x^T z$ | pas d'application, redonne le SVM linéaire |
142
| Polynomial | $(x^T z + c)^d$ | degré $d$, décalage $c$ |
143
| Gaussien (RBF) | $\exp\!\big(-\tfrac{\lVert x - z \rVert^2}{2\sigma^2}\big)$ | dimension infinie, local |
144
145
*Remarque :* un petit $\sigma$ rend le noyau RBF très local, ce qui peut surapprendre. Il se règle
146
en compromis avec $C$.
147
148
![Frontière de décision avec noyau RBF](/fr/Machine%20Learning/04%20Support%20Vector%20Machines/a/svm-kernel.png)
149
150
*Un noyau RBF sépare des classes non linéairement séparables, par une frontière non linéaire dans l'espace d'entrée.*
151
d5b8b5 lugonthier 2026-07-01 14:24:01
Refactor section headings for consistency and clarity across multiple documents in the Machine Learning module. Updated headings to include numerical prefixes for better organization and navigation. Adjusted content formatting and improved terminology in French translations for decision trees, ensemble methods, and other foundational concepts.
152
## 4.4 Lagrangien et dualité
1c3139 Lucas Gonthier 2026-06-30 12:04:21
Initial commit: course content (Machine Learning, MLOps) in EN and FR Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
153
d5b8b5 lugonthier 2026-07-01 14:24:01
Refactor section headings for consistency and clarity across multiple documents in the Machine Learning module. Updated headings to include numerical prefixes for better organization and navigation. Adjusted content formatting and improved terminology in French translations for decision trees, ensemble methods, and other foundational concepts.
154
### 4.4.1 Lagrangien
1c3139 Lucas Gonthier 2026-06-30 12:04:21
Initial commit: course content (Machine Learning, MLOps) in EN and FR Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
155
156
Pour un objectif primal $f(w)$ avec contraintes d'inégalité $g_i(w) \le 0$ et multiplicateurs
157
$\beta_i \ge 0$, le lagrangien est défini comme :
158
159
$$\boxed{ \mathcal{L}(w,\beta) = f(w) + \sum_{i=1}^{m} \beta_i \, g_i(w) }$$
160
161
Appliqué au primal SVM $\tfrac{1}{2}\lVert w \rVert^2$ avec contraintes
162
$1 - y^{(i)}(w^T x^{(i)} - b) \le 0$, les conditions de stationnarité $\nabla_w \mathcal{L} = 0$ et
163
$\partial_b \mathcal{L} = 0$ donnent :
164
165
$$\boxed{ w = \sum_{i=1}^{m} \beta_i\, y^{(i)} x^{(i)}, \qquad \sum_{i=1}^{m} \beta_i\, y^{(i)} = 0 }$$
166
167
Le $w$ optimal est donc une combinaison linéaire des entrées d'apprentissage pondérées par
168
$\beta_i y^{(i)}$.
169
d5b8b5 lugonthier 2026-07-01 14:24:01
Refactor section headings for consistency and clarity across multiple documents in the Machine Learning module. Updated headings to include numerical prefixes for better organization and navigation. Adjusted content formatting and improved terminology in French translations for decision trees, ensemble methods, and other foundational concepts.
170
### 4.4.2 Problème dual
1c3139 Lucas Gonthier 2026-06-30 12:04:21
Initial commit: course content (Machine Learning, MLOps) in EN and FR Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
171
172
En réinjectant ces relations, on élimine $w$ et $b$, ce qui laisse un problème en $\beta$ ne
173
dépendant des données qu'à travers des produits scalaires :
174
175
$$\boxed{ \max_{\beta} \ \sum_{i=1}^{m}\beta_i - \tfrac{1}{2}\sum_{i,j}\beta_i \beta_j\, y^{(i)} y^{(j)} \langle x^{(i)}, x^{(j)} \rangle \quad \text{s.c.} \quad \beta_i \ge 0, \ \ \sum_{i}\beta_i y^{(i)} = 0 }$$
176
d5b8b5 lugonthier 2026-07-01 14:24:01
Refactor section headings for consistency and clarity across multiple documents in the Machine Learning module. Updated headings to include numerical prefixes for better organization and navigation. Adjusted content formatting and improved terminology in French translations for decision trees, ensemble methods, and other foundational concepts.
177
Les produits scalaires sont exactement l'endroit où l'on substitue un noyau $K$ (voir [Noyaux](/fr/Machine%20Learning/04%20Support%20Vector%20Machines#43-noyaux)).
1c3139 Lucas Gonthier 2026-06-30 12:04:21
Initial commit: course content (Machine Learning, MLOps) in EN and FR Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
178
d5b8b5 lugonthier 2026-07-01 14:24:01
Refactor section headings for consistency and clarity across multiple documents in the Machine Learning module. Updated headings to include numerical prefixes for better organization and navigation. Adjusted content formatting and improved terminology in French translations for decision trees, ensemble methods, and other foundational concepts.
179
### 4.4.3 KKT et vecteurs de support
1c3139 Lucas Gonthier 2026-06-30 12:04:21
Initial commit: course content (Machine Learning, MLOps) in EN and FR Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
180
181
À l'optimum, l'écart complémentaire lie chaque multiplicateur à sa contrainte :
182
183
$$\boxed{ \beta_i \big[\, y^{(i)}(w^T x^{(i)} - b) - 1 \,\big] = 0 }$$
184
185
Les vecteurs de support sont définis comme les exemples à multiplicateur non nul :
186
187
$$\boxed{ \text{vecteurs de support} = \{\, i : \beta_i > 0 \,\} }$$
188
189
Ce sont les points exactement sur la marge. Tous les autres ont $\beta_i = 0$ et n'influencent pas
190
$w$.
191
d5b8b5 lugonthier 2026-07-01 14:24:01
Refactor section headings for consistency and clarity across multiple documents in the Machine Learning module. Updated headings to include numerical prefixes for better organization and navigation. Adjusted content formatting and improved terminology in French translations for decision trees, ensemble methods, and other foundational concepts.
192
### 4.4.4 Décision à noyau
1c3139 Lucas Gonthier 2026-06-30 12:04:21
Initial commit: course content (Machine Learning, MLOps) in EN and FR Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
193
194
Remplacer le produit scalaire par un noyau donne une règle de décision exprimée uniquement à
195
travers les vecteurs de support :
196
197
$$\boxed{ h(x) = \operatorname{sign}\!\left( \sum_{i=1}^{m} \beta_i\, y^{(i)}\, K(x^{(i)}, x) - b \right) }$$
198
199
*Remarque :* seuls les vecteurs de support ($\beta_i > 0$) contribuent, donc le coût de prédiction
200
croît avec leur nombre, pas avec $m$.
201
d5b8b5 lugonthier 2026-07-01 14:24:01
Refactor section headings for consistency and clarity across multiple documents in the Machine Learning module. Updated headings to include numerical prefixes for better organization and navigation. Adjusted content formatting and improved terminology in French translations for decision trees, ensemble methods, and other foundational concepts.
202
### 4.4.5 Du primal à la décision
1c3139 Lucas Gonthier 2026-06-30 12:04:21
Initial commit: course content (Machine Learning, MLOps) in EN and FR Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
203
204
```mermaid
205
flowchart TD
206
A["QP primal : minimiser demi norme au carre"]
207
B["lagrangien avec multiplicateurs"]
208
C["probleme dual en beta"]
209
D["conditions KKT"]
210
E["vecteurs de support : beta superieur a zero"]
211
F["regle de decision a noyau"]
212
A --> B
213
B --> C
214
C --> D
215
D --> E
216
E --> F
217
```
218
219
*Les machines à vecteurs de support tracent une seule frontière, éventuellement à noyau. La dernière partie suit une autre voie : découper l'espace des variables par des règles simples et combiner de nombreux modèles en un ensemble.*
220
221
---
222
Suivant : [Arbres de décision et méthodes d'ensemble](/fr/Machine%20Learning/05%20Decision%20trees%20and%20ensemble%20methods) · [Vue d'ensemble du cours](/fr/Machine%20Learning)