Blame

0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
1
# 4. Régression linéaire
2
3
La régression linéaire prédit une cible continue à partir d'un score linéaire. Ce module suit un seul fil de bout en bout : poser le modèle, l'ajuster à des données bruitées par moindres carrés, justifier cet objectif par le maximum de vraisemblance, le régulariser par le maximum a posteriori (ridge, puis son cousin sélectif le lasso), puis élargir le modèle avec les fonctions de base et les prédictions multiples, où les deux mêmes formes closes reviennent inchangées.
4
5
## 4.1 Le modèle linéaire
6
7
L'hypothèse est linéaire en l'entrée augmentée $x \in \mathbb{R}^{n+1}$ avec $x_0 = 1$, la convention de l'[Introduction](/fr/Machine%20Learning/01%20Introduction) :
8
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
9
$$\boxed{ h_w(x) = w^T x = w_0 + w_1 x_1 + \dots + w_n x_n }$$
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
10
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
11
$w_0$ est le biais (l'ordonnée à l'origine) et les autres coordonnées sont les poids, et replier le biais dans le produit scalaire est exactement ce que la convention $x_0 = 1$ apporte. Géométriquement, la prédiction est une droite pour $n = 1$, un plan pour $n = 2$, un hyperplan au-delà.
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
12
13
![La prédiction est une droite, puis un plan](/fr/Machine%20Learning/04%20Linear%20regression/a/line-and-plane.png)
14
15
*Avec une caractéristique le modèle trace une droite à travers les données, avec deux un plan, et au-delà un hyperplan que l'on ne peut plus dessiner.*
16
17
## 4.2 Le problème à résoudre
18
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
19
Étant donné l'ensemble d'entraînement $\{(x^{(i)}, y^{(i)})\}_{i=1}^{m}$, on voudrait idéalement $h_w(x^{(i)}) = y^{(i)}$ en chaque point. Les cibles réelles sont bruitées (erreurs de mesure, facteurs non modélisés), aucune droite ne passe donc par toutes, et le but devient de commettre la plus petite erreur totale. Les moindres carrés prennent le résidu au carré comme erreur et le somment sur l'ensemble d'entraînement :
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
20
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
21
$$\boxed{ w^{*} = \arg\min_w \; \sum_{i=1}^{m}\left(w^T x^{(i)} - y^{(i)}\right)^2 }$$
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
22
23
![Cibles idéales et cibles bruitées](/fr/Machine%20Learning/04%20Linear%20regression/a/ideal-vs-noisy.png)
24
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
25
*À gauche : si les cibles étaient sans bruit, le modèle pourrait passer par chaque point. À droite : les cibles réelles se dispersent autour de la tendance, chaque point laisse donc un résidu entre $y^{(i)}$ et la prédiction $h_w(x^{(i)})$, et l'ajustement minimise leur somme des carrés (segments gris).*
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
26
27
*Remarque :* pourquoi le carré plutôt que, disons, la valeur absolue ? Parce que ce choix est prouvé optimal quand le bruit est gaussien, une question d'entrevue classique que la section suivante décortique.
28
29
## 4.3 Maximum de vraisemblance : les moindres carrés justifiés
30
31
Donnons aux données une histoire générative, avec le principe d'estimation de la [Formulation probabiliste](/fr/Machine%20Learning/03%20Probabilistic%20formulation) : chaque cible est la prédiction linéaire plus un bruit gaussien indépendant,
32
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
33
$$\boxed{ y^{(i)} = w^T x^{(i)} + \varepsilon^{(i)}, \quad \varepsilon^{(i)} \sim \mathcal{N}(0, \sigma^2) }$$
34
35
donc $p(y^{(i)} \mid x^{(i)}; w) = \mathcal{N}(w^T x^{(i)}, \sigma^2)$. Le maximum de vraisemblance choisit les paramètres sous lesquels les cibles observées sont les plus probables, et il livre deux résultats. D'abord, maximiser la vraisemblance revient exactement à minimiser la somme des erreurs au carré :
36
37
$$\boxed{ w_{\mathrm{MV}} = \arg\max_w \; p(y \mid X; w) = \arg\min_w \; \sum_{i=1}^{m}\left(y^{(i)} - w^T x^{(i)}\right)^2 }$$
38
39
Ensuite, le minimiseur a une forme close, l'équation normale, avec $X$ la matrice de conception dont les lignes sont les $x^{(i)T}$ :
40
41
$$\boxed{ w_{\mathrm{MV}} = (X^T X)^{-1}X^T y }$$
42
43
une résolution matricielle entre les données et le modèle.
44
45
*Remarque :* la première boîte est le fait le plus important du module. Les moindres carrés ne sont pas une convention commode, ils sont l'estimation du maximum de vraisemblance sous bruit gaussien.
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
46
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
47
<details class="proof">
48
<summary>Preuve : maximiser la vraisemblance, c'est minimiser l'erreur quadratique</summary>
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
49
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
50
Les exemples sont i.i.d., la vraisemblance de tout l'ensemble d'entraînement se factorise donc en un produit de densités gaussiennes :
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
51
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
52
$$p(y \mid X; w) = \prod_{i=1}^{m} p(y^{(i)} \mid x^{(i)}; w) = \prod_{i=1}^{m} \frac{1}{\sqrt{2\pi\sigma^2}}\, \exp\!\left(-\frac{\left(y^{(i)} - w^T x^{(i)}\right)^2}{2\sigma^2}\right)$$
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
53
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
54
Le logarithme est croissant, il préserve donc l'argmax et transforme le produit en somme, la log-vraisemblance, qui se sépare en une constante et la somme des carrés :
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
55
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
56
$$\ell(w) = \sum_{i=1}^{m} \log \mathcal{N}\!\left(y^{(i)} \mid w^T x^{(i)}, \sigma^2\right) = -\frac{m}{2}\log(2\pi\sigma^2) \;-\; \frac{1}{2\sigma^2}\sum_{i=1}^{m}\left(y^{(i)} - w^T x^{(i)}\right)^2$$
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
57
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
58
Le premier terme ne dépend pas de $w$ et le facteur $\tfrac{1}{2\sigma^2}$ est une constante positive, aucun des deux ne déplace donc l'argmax. Maximiser $\ell$ revient donc à minimiser la somme des erreurs au carré. $\blacksquare$
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
59
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
60
</details>
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
61
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
62
<details class="proof">
63
<summary>Preuve : l'équation normale</summary>
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
64
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
65
Avec la matrice de conception, la somme des carrés est la quadratique $\lVert Xw - y \rVert^2$, une fonction convexe de $w$, son minimum global est donc le point de gradient nul :
66
67
$$\nabla_w\, \lVert Xw - y \rVert^2 = 2\,X^T(Xw - y) = 0 \;\Longleftrightarrow\; X^T X\, w = X^T y$$
68
69
Pourvu que $X^T X$ soit inversible (caractéristiques indépendantes, plus d'exemples que de caractéristiques), isoler $w$ donne $w_{\mathrm{MV}} = (X^T X)^{-1}X^T y$. $\blacksquare$
70
71
</details>
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
72
73
## 4.4 Maximum a posteriori : la régression ridge
74
75
Le maximum de vraisemblance peut surapprendre, surtout quand le modèle est flexible. L'estimation du maximum a posteriori maximise plutôt l'a posteriori, qui par la règle de Bayes est la vraisemblance multipliée par un a priori sur les paramètres, ici une gaussienne centrée :
76
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
77
$$w_{\mathrm{MAP}} = \arg\max_w \; p(y \mid X, w)\, p(w), \qquad w \sim \mathcal{N}(0, \tau^2 I)$$
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
78
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
79
Deux résultats à nouveau. L'a priori gaussien se transforme en une pénalité L2 ajoutée aux moindres carrés :
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
80
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
81
$$\boxed{ w_{\mathrm{MAP}} = \arg\min_w \; \sum_{i=1}^{m}\left(y^{(i)} - w^T x^{(i)}\right)^2 + \lambda \lVert w \rVert_2^2, \quad \lambda = \frac{\sigma^2}{\tau^2} }$$
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
82
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
83
et le minimiseur pénalisé garde une forme close :
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
84
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
85
$$\boxed{ w_{\mathrm{MAP}} = (X^T X + \lambda I)^{-1}X^T y }$$
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
86
87
C'est la régression ridge, et la pénalité est souvent appelée weight decay. L'a priori gaussien est devenu la pénalité L2 de [Concepts généraux](/fr/Machine%20Learning/02%20General%20concepts), exactement le lien a priori vers pénalité de la [Formulation probabiliste](/fr/Machine%20Learning/03%20Probabilistic%20formulation).
88
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
89
*Remarque :* $\lambda \to 0$ retrouve le maximum de vraisemblance, et un $\lambda$ croissant rétrécit $w$ vers zéro et combat le surapprentissage. Un a priori plus fort (petit $\tau$) signifie un $\lambda$ plus grand. Notons aussi que $X^T X + \lambda I$ est toujours inversible pour $\lambda > 0$, ce qui sauve les moindres carrés exactement là où ils s'effondrent : des caractéristiques fortement corrélées, ou plus de caractéristiques que d'exemples.
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
90
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
91
<details class="proof">
92
<summary>Preuve : l'a priori gaussien devient la pénalité L2</summary>
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
93
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
94
Par la règle de Bayes, l'a posteriori est
95
96
$$p(w \mid y, X) = \frac{p(y \mid X, w)\, p(w)}{p(y \mid X)}$$
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
97
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
98
et le dénominateur ne dépend pas de $w$, maximiser l'a posteriori revient donc à maximiser la vraisemblance multipliée par l'a priori. La covariance de l'a priori est généralement inconnue, on la suppose donc isotropique, $\tau^2 I$, ce qui donne la densité
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
99
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
100
$$p(w) = \frac{1}{(2\pi\tau^2)^{(n+1)/2}}\, \exp\!\left(-\frac{\lVert w \rVert^2}{2\tau^2}\right)$$
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
101
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
102
En prenant le logarithme et en réutilisant la log-vraisemblance $\ell(w)$ de la preuve précédente,
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
103
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
104
$$\log p(y \mid X, w) + \log p(w) = \mathrm{const} \;-\; \frac{1}{2\sigma^2}\sum_{i=1}^{m}\left(y^{(i)} - w^T x^{(i)}\right)^2 \;-\; \frac{1}{2\tau^2}\lVert w \rVert^2$$
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
105
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
106
où la constante rassemble tous les termes indépendants de $w$. Multiplier par $-2\sigma^2$, une constante négative qui change l'argmax en argmin, laisse
107
108
$$w_{\mathrm{MAP}} = \arg\min_w \; \sum_{i=1}^{m}\left(y^{(i)} - w^T x^{(i)}\right)^2 + \frac{\sigma^2}{\tau^2}\, \lVert w \rVert^2$$
109
110
et $\lambda = \sigma^2 / \tau^2$ nomme le rapport : plus les données sont bruitées ou plus l'a priori est serré, plus la pénalité est lourde. $\blacksquare$
111
112
</details>
113
114
<details class="proof">
115
<summary>Preuve : la forme close du ridge</summary>
116
117
Sous forme matricielle, l'objectif est $\lVert Xw - y \rVert^2 + \lambda \lVert w \rVert^2$, toujours une quadratique convexe, la condition de gradient nul trouve donc son minimum global :
118
119
$$\nabla_w \left( \lVert Xw - y \rVert^2 + \lambda \lVert w \rVert^2 \right) = 2\,X^T(Xw - y) + 2\lambda w = 0 \;\Longleftrightarrow\; (X^T X + \lambda I)\, w = X^T y$$
120
121
Pour $\lambda > 0$, la matrice $X^T X + \lambda I$ est définie positive, donc inversible, sans condition sur $X$ cette fois : pour tout $v \neq 0$, $v^T (X^T X + \lambda I)\, v = \lVert X v \rVert^2 + \lambda \lVert v \rVert^2 > 0$. Isoler $w$ donne $w_{\mathrm{MAP}} = (X^T X + \lambda I)^{-1} X^T y$. $\blacksquare$
122
123
</details>
124
125
## 4.5 Le lasso : une pénalité qui sélectionne
126
127
La pénalité ridge venait d'un a priori gaussien. Un a priori de Laplace donne plutôt la pénalité L1, le lien noté dans la [Formulation probabiliste](/fr/Machine%20Learning/03%20Probabilistic%20formulation) :
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
128
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
129
$$\boxed{ w_{\mathrm{lasso}} = \arg\min_w \; \sum_{i=1}^{m}\left(y^{(i)} - w^T x^{(i)}\right)^2 + \lambda \lVert w \rVert_1 }$$
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
130
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
131
Le changement paraît minime, ses conséquences non :
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
132
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
133
- **Il sélectionne.** Le lasso met certains coefficients exactement à zéro, opérant une sélection de variables tout en ajustant. Le ridge ne fait que rétrécir, sans jamais annuler : le ridge stabilise, le lasso sélectionne.
134
- **La raison est géométrique.** La région de contrainte $\lVert w \rVert_1 \le t$ est un losange dont les coins sont sur les axes, et les contours elliptiques de l'erreur quadratique tendent à toucher un coin d'abord, là où une coordonnée est nulle. La boule L2 arrondie n'a pas de coins à accrocher.
135
- **$\lambda$ trace un chemin.** Quand $\lambda$ grandit, les coefficients atteignent exactement zéro l'un après l'autre, du modèle complet jusqu'au modèle vide. Comme toujours, $\lambda$ se choisit par la validation croisée de [Concepts généraux](/fr/Machine%20Learning/02%20General%20concepts), souvent le plus grand $\lambda$ à un écart-type du meilleur.
136
- **Pas de forme close.** La pénalité L1 n'est pas dérivable en zéro, le lasso s'ajuste donc par des solveurs convexes plutôt que par une formule.
137
- **L'elastic net** mêle les deux pénalités, $\lambda\left(\alpha \lVert w \rVert_1 + (1-\alpha)\lVert w \rVert_2^2\right)$, gardant la sélection du lasso avec la stabilité du ridge face aux caractéristiques corrélées.
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
138
139
*Remarque :* prédire n'est pas inférer. Sélectionner des variables par lasso puis rapporter les écarts-types des manuels sur les mêmes données est invalide, la malédiction du vainqueur encore : les intervalles ignorent que les données ont déjà choisi les variables. Une inférence honnête demande une division de l'échantillon ou un estimateur débiaisé, la porte d'entrée du machine learning causal.
140
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
141
## 4.6 Fonctions de base : non linéaire en $x$, linéaire en $w$
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
142
143
Une droite est souvent trop rigide : le sous-apprentissage de [Concepts généraux](/fr/Machine%20Learning/02%20General%20concepts) apparaissait précisément quand un modèle à faible capacité rencontrait une tendance courbe. La solution n'est pas d'abandonner la machinerie linéaire mais de projeter l'entrée dans un espace plus grand, là où la relation est linéaire :
144
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
145
$$\boxed{ h_w(x) = w^T \phi(x) = \sum_{j=0}^{M-1} w_j\, \phi_j(x), \qquad \phi_0(x) = 1 }$$
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
146
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
147
Les $\phi_j$ sont des fonctions de base, fixées avant l'entraînement. Avec $\phi(x) = (1, x, x^2, \dots, x^d)$ elles donnent la régression polynomiale, l'exemple fil rouge de [Concepts généraux](/fr/Machine%20Learning/02%20General%20concepts), et l'identité $\phi(x) = x$ retrouve tout ce qui précède. Le modèle peut désormais être follement non linéaire en $x$ tout en restant linéaire en $w$, rien ne change donc dans l'ajustement : on empile les $\phi(x^{(i)})^T$ comme lignes de la matrice de conception $\Phi \in \mathbb{R}^{m \times M}$ et les deux formes closes reviennent telles quelles :
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
148
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
149
$$\boxed{ w_{\mathrm{MV}} = (\Phi^T \Phi)^{-1}\Phi^T y, \qquad w_{\mathrm{MAP}} = (\Phi^T \Phi + \lambda I)^{-1}\Phi^T y }$$
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
150
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
151
*Remarque :* la base (sa famille et sa taille $M$) est un hyperparamètre, choisi avant l'entraînement, tandis que $w$ est appris. Choisir $M$ et $\lambda$ est le problème de sélection de modèle réglé par la validation croisée de [Concepts généraux](/fr/Machine%20Learning/02%20General%20concepts).
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
152
153
## 4.7 Prédictions multiples
154
155
Rien ne restreint la cible à un seul nombre. Pour prédire $K$ valeurs à la fois (disons le prix d'une maison, son coût de chauffage et ses taxes à partir des mêmes caractéristiques), on prend $y^{(i)} \in \mathbb{R}^K$ et on donne à chaque sortie sa propre colonne de paramètres, rassemblées dans une matrice $W \in \mathbb{R}^{M \times K}$ :
156
157
$$\boxed{ h_W(x) = W^T \phi(x) \in \mathbb{R}^{K} }$$
158
159
En empilant les cibles comme lignes de $Y \in \mathbb{R}^{m \times K}$, les mêmes dérivations donnent les mêmes formes closes, qui résolvent les $K$ régressions d'un coup :
160
161
$$\boxed{ W_{\mathrm{MV}} = (\Phi^T \Phi)^{-1}\Phi^T Y, \qquad W_{\mathrm{MAP}} = (\Phi^T \Phi + \lambda I)^{-1}\Phi^T Y }$$
162
163
*Remarque :* le facteur coûteux $(\Phi^T \Phi)^{-1}$ ne dépend pas des cibles, il se calcule donc une seule fois et se partage entre les $K$ sorties.
164
165
## 4.8 Résumé
166
167
| | Formule |
168
| --- | --- |
6b31d5 lugonthier 2026-07-15 12:37:13
feat: Update "Decision trees and ensemble methods" module with new content and visuals - Revamped the introduction to ensemble methods, emphasizing the benefits of combining models. - Expanded sections on decision trees, bagging, and boosting, including detailed explanations and formulas. - Added new SVG diagrams illustrating the bagging process, the transition from stumps to trees, and variance reduction. - Introduced new images for AdaBoost rounds and variance reduction to enhance understanding.
169
| Modèle | $h_w(x) = w^T \phi(x)$ |
170
| Maximum de vraisemblance (moindres carrés) | $w_{\mathrm{MV}} = (\Phi^T \Phi)^{-1}\Phi^T y$ |
171
| Maximum a posteriori (ridge) | $w_{\mathrm{MAP}} = (\Phi^T \Phi + \lambda I)^{-1}\Phi^T y$ |
172
| Paramètres, appris | $w$ (ou $W$ pour $K$ sorties) |
0ad9b6 lugonthier 2026-07-10 12:03:30
Remove "07 Regularization and high-dimensional inference" chapter and add "07 Support Vector Machines" and "08 Decision trees and ensemble methods" chapters with corresponding images.
173
| Hyperparamètres, choisis par validation | la base $\phi$ et sa taille $M$, la pénalité $\lambda$ |
174
175
*Le même score linéaire, passé dans une fonction de compression au lieu d'être lu directement, transforme la régression en classification, le sujet du module suivant.*
176
177
---
178
Suivant : [Classification linéaire](/fr/Machine%20Learning/05%20Linear%20classification) · [Vue d'ensemble du cours](/fr/Machine%20Learning)