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
# 3. Probabilistic formulation
e0287e lugonthier 2026-07-02 15:52:15
Add new content and images for machine learning and mathematics modules - Added images for regularization and high-dimensional inference. - Introduced Support Vector Machines (SVM) module with detailed explanations and images. - Created Decision Trees and Ensemble Methods module with comprehensive content and illustrations. - Added a Mathematics overview module and a refresher on mathematical concepts essential for machine learning. - Included SVG diagrams for Bayes' rule and multivariate Gaussian distribution.
2
3
Probability is the language machine learning uses to handle uncertainty. This module sets out the rules for discrete and continuous variables, takes a first look at information theory, shows the Bayesian way of turning probabilities into decisions, and defines the two estimation principles the course returns to again and again: maximum likelihood and maximum a posteriori.
4
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.
5
## 3.1 Probability, discrete and continuous
e0287e lugonthier 2026-07-02 15:52:15
Add new content and images for machine learning and mathematics modules - Added images for regularization and high-dimensional inference. - Introduced Support Vector Machines (SVM) module with detailed explanations and images. - Created Decision Trees and Ensemble Methods module with comprehensive content and illustrations. - Added a Mathematics overview module and a refresher on mathematical concepts essential for machine learning. - Included SVG diagrams for Bayes' rule and multivariate Gaussian distribution.
6
7
A random variable takes values with probabilities that are non-negative and sum or integrate to one. A discrete variable has a probability mass function, a continuous one a probability density function:
8
9
$$\boxed{ \sum_x p(x) = 1 \qquad \int p(x)\, dx = 1, \quad p(x) \ge 0 }$$
10
11
For a continuous variable, probability attaches to intervals through an integral, $P(a \le X \le b) = \int_a^b p(x)\, dx$, not to single points.
12
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.
13
## 3.2 Joint, conditional, and Bayes
e0287e lugonthier 2026-07-02 15:52:15
Add new content and images for machine learning and mathematics modules - Added images for regularization and high-dimensional inference. - Introduced Support Vector Machines (SVM) module with detailed explanations and images. - Created Decision Trees and Ensemble Methods module with comprehensive content and illustrations. - Added a Mathematics overview module and a refresher on mathematical concepts essential for machine learning. - Included SVG diagrams for Bayes' rule and multivariate Gaussian distribution.
14
15
Two variables have a joint distribution $p(x, y)$. Summing (or integrating) out one variable gives the marginal, the sum rule, and the joint factors into a conditional times a marginal, the product rule:
16
17
$$\boxed{ p(x) = \sum_y p(x, y) \qquad p(x, y) = p(y \mid x)\, p(x) }$$
18
19
Rearranging the product rule both ways gives Bayes' rule, which flips a conditional:
20
21
$$\boxed{ p(y \mid x) = \frac{p(x \mid y)\, p(y)}{p(x)} }$$
22
23
Two variables are independent when the joint is the product of the marginals, $p(x, y) = p(x)\, p(y)$.
24
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.
25
## 3.3 A little information theory
e0287e lugonthier 2026-07-02 15:52:15
Add new content and images for machine learning and mathematics modules - Added images for regularization and high-dimensional inference. - Introduced Support Vector Machines (SVM) module with detailed explanations and images. - Created Decision Trees and Ensemble Methods module with comprehensive content and illustrations. - Added a Mathematics overview module and a refresher on mathematical concepts essential for machine learning. - Included SVG diagrams for Bayes' rule and multivariate Gaussian distribution.
26
27
The entropy of a distribution measures its uncertainty, the average number of bits needed to describe an outcome:
28
29
$$\boxed{ H(X) = -\sum_x p(x)\log p(x) }$$
30
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.
31
![Binary entropy](/en/Machine%20Learning/03%20Probabilistic%20formulation/a/entropy.png)
e0287e lugonthier 2026-07-02 15:52:15
Add new content and images for machine learning and mathematics modules - Added images for regularization and high-dimensional inference. - Introduced Support Vector Machines (SVM) module with detailed explanations and images. - Created Decision Trees and Ensemble Methods module with comprehensive content and illustrations. - Added a Mathematics overview module and a refresher on mathematical concepts essential for machine learning. - Included SVG diagrams for Bayes' rule and multivariate Gaussian distribution.
32
33
*For a two-outcome variable the entropy is largest at $p = 0.5$, where the outcome is hardest to predict, and zero when one outcome is certain.*
34
35
The cross-entropy measures the cost of using a model $q$ when the truth is $p$, and the Kullback-Leibler divergence measures how far $q$ sits from $p$:
36
37
$$\boxed{ H(p, q) = -\sum_x p(x)\log q(x) \qquad D_{\mathrm{KL}}(p \,\|\, q) = \sum_x p(x)\log\frac{p(x)}{q(x)} \ge 0 }$$
38
39
*Remark:* minimizing the cross-entropy between the true labels and a model's predictions is the same as maximizing the likelihood of those labels. This is why classification networks minimize cross-entropy, a thread picked up in later modules.
40
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.
41
## 3.4 Bayesian decision theory
e0287e lugonthier 2026-07-02 15:52:15
Add new content and images for machine learning and mathematics modules - Added images for regularization and high-dimensional inference. - Introduced Support Vector Machines (SVM) module with detailed explanations and images. - Created Decision Trees and Ensemble Methods module with comprehensive content and illustrations. - Added a Mathematics overview module and a refresher on mathematical concepts essential for machine learning. - Included SVG diagrams for Bayes' rule and multivariate Gaussian distribution.
42
43
To classify an input $x$, the Bayesian rule uses the posterior over classes. Under the 0-1 loss, the decision that minimizes the expected loss is simply the most probable class, and because the posterior is proportional to the class-conditional density times the prior, it can be computed either way:
44
45
$$\boxed{ \hat{y} = \arg\max_y \; p(y \mid x) = \arg\max_y \; p(x \mid y)\, p(y) }$$
46
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.
47
![Bayesian decision between two classes](/en/Machine%20Learning/03%20Probabilistic%20formulation/a/bayes-decision.png)
e0287e lugonthier 2026-07-02 15:52:15
Add new content and images for machine learning and mathematics modules - Added images for regularization and high-dimensional inference. - Introduced Support Vector Machines (SVM) module with detailed explanations and images. - Created Decision Trees and Ensemble Methods module with comprehensive content and illustrations. - Added a Mathematics overview module and a refresher on mathematical concepts essential for machine learning. - Included SVG diagrams for Bayes' rule and multivariate Gaussian distribution.
48
49
*Each class contributes its density scaled by its prior, and the decision boundary falls where the two are equal. On each side the class with the larger posterior wins.*
50
51
*Remark:* this is the optimal classifier, called the Bayes classifier. Every method later in the course is, in effect, an attempt to approximate these posteriors from data.
52
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
## 3.5 Maximum likelihood and maximum a posteriori
e0287e lugonthier 2026-07-02 15:52:15
Add new content and images for machine learning and mathematics modules - Added images for regularization and high-dimensional inference. - Introduced Support Vector Machines (SVM) module with detailed explanations and images. - Created Decision Trees and Ensemble Methods module with comprehensive content and illustrations. - Added a Mathematics overview module and a refresher on mathematical concepts essential for machine learning. - Included SVG diagrams for Bayes' rule and multivariate Gaussian distribution.
54
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.
55
We rarely know the true distribution, so we estimate its parameters $w$ from data. Maximum likelihood picks the $w$ that makes the observed data most probable, usually maximized as a sum of log-likelihoods over the $m$ examples:
e0287e lugonthier 2026-07-02 15:52:15
Add new content and images for machine learning and mathematics modules - Added images for regularization and high-dimensional inference. - Introduced Support Vector Machines (SVM) module with detailed explanations and images. - Created Decision Trees and Ensemble Methods module with comprehensive content and illustrations. - Added a Mathematics overview module and a refresher on mathematical concepts essential for machine learning. - Included SVG diagrams for Bayes' rule and multivariate Gaussian distribution.
56
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.
57
$$\boxed{ w_{\mathrm{MLE}} = \arg\max_w \sum_{i=1}^{m} \log p(x^{(i)} \mid w) }$$
e0287e lugonthier 2026-07-02 15:52:15
Add new content and images for machine learning and mathematics modules - Added images for regularization and high-dimensional inference. - Introduced Support Vector Machines (SVM) module with detailed explanations and images. - Created Decision Trees and Ensemble Methods module with comprehensive content and illustrations. - Added a Mathematics overview module and a refresher on mathematical concepts essential for machine learning. - Included SVG diagrams for Bayes' rule and multivariate Gaussian distribution.
58
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.
59
In supervised learning the model parameterizes the conditional $p(y \mid x; w)$, so the same principle applies to the conditional likelihood of the targets:
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.
60
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.
61
$$\boxed{ \ell(w) = \sum_{i=1}^{m} \log p\!\left(y^{(i)} \mid x^{(i)}; w\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.
62
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.
63
Maximizing $\ell$ is the same as minimizing the cost $J(w) = -\ell(w)$, so the likelihood view and the cost-minimization view of [General concepts](/en/Machine%20Learning/02%20General%20concepts) are two faces of one objective.
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
Maximum a posteriori instead maximizes the posterior, which multiplies the likelihood by a prior on $w$:
e0287e lugonthier 2026-07-02 15:52:15
Add new content and images for machine learning and mathematics modules - Added images for regularization and high-dimensional inference. - Introduced Support Vector Machines (SVM) module with detailed explanations and images. - Created Decision Trees and Ensemble Methods module with comprehensive content and illustrations. - Added a Mathematics overview module and a refresher on mathematical concepts essential for machine learning. - Included SVG diagrams for Bayes' rule and multivariate Gaussian distribution.
66
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.
67
$$\boxed{ w_{\mathrm{MAP}} = \arg\max_w \; p(D \mid w)\, p(w) }$$
e0287e lugonthier 2026-07-02 15:52:15
Add new content and images for machine learning and mathematics modules - Added images for regularization and high-dimensional inference. - Introduced Support Vector Machines (SVM) module with detailed explanations and images. - Created Decision Trees and Ensemble Methods module with comprehensive content and illustrations. - Added a Mathematics overview module and a refresher on mathematical concepts essential for machine learning. - Included SVG diagrams for Bayes' rule and multivariate Gaussian distribution.
68
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.
69
*Remark:* maximum a posteriori is maximum likelihood plus a prior. A Gaussian prior on $w$ becomes an L2 penalty and a Laplace prior an L1 penalty, which is exactly the regularization of the next module. With abundant data the prior washes out and the two estimators agree.
e0287e lugonthier 2026-07-02 15:52:15
Add new content and images for machine learning and mathematics modules - Added images for regularization and high-dimensional inference. - Introduced Support Vector Machines (SVM) module with detailed explanations and images. - Created Decision Trees and Ensemble Methods module with comprehensive content and illustrations. - Added a Mathematics overview module and a refresher on mathematical concepts essential for machine learning. - Included SVG diagrams for Bayes' rule and multivariate Gaussian distribution.
70
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.
71
*The next module turns these principles into a first concrete model: linear regression, where maximum likelihood and maximum a posteriori both land on closed-form fits.*
e0287e lugonthier 2026-07-02 15:52:15
Add new content and images for machine learning and mathematics modules - Added images for regularization and high-dimensional inference. - Introduced Support Vector Machines (SVM) module with detailed explanations and images. - Created Decision Trees and Ensemble Methods module with comprehensive content and illustrations. - Added a Mathematics overview module and a refresher on mathematical concepts essential for machine learning. - Included SVG diagrams for Bayes' rule and multivariate Gaussian distribution.
72
73
---
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.
74
Next: [Linear regression](/en/Machine%20Learning/04%20Linear%20regression) · [Course overview](/en/Machine%20Learning)