Skip to content

Commit 953f51b

Browse files
Add files via upload
0 parents  commit 953f51b

65 files changed

Lines changed: 22359 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

00-chapter.Rmd

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Table of Symbols {-}
2+
3+
### Important Symbols and Where to Find Them: {-}
4+
5+
| **Symbol** | **Typical Meaning** | **Reference**|
6+
|:-------|:--------------------|:-------|
7+
| *a, b, c, α, β, γ* | Scalars (lowercase) | |
8+
| **x, y, z** | Vectors (bold lowercase) | Section 1.1, 2.0|
9+
| **A, B, C** | Matrices (bold uppercase) | |
10+
| \( x^\top, A^\top \) | Transpose of a vector or matrix | |
11+
| \( A^{-1} \) | Inverse of a matrix | |
12+
| \( \langle x, y \rangle \) | Inner product of \(x\) and \(y\) | |
13+
| \( x^\top y \) | Dot product of \(x\) and \(y\) | Section 2.0 |
14+
| \( B = (b_1, b_2, b_3) \) | Ordered tuple |
15+
| \( B = [b_1, b_2, b_3] \) | Matrix of column vectors stacked horizontally |
16+
| \( B = \{b_1, b_2, b_3\} \) | Set of vectors (unordered) |
17+
| \( \mathbb{Z}, \mathbb{N} \) | Integers and natural numbers |
18+
| \( \mathbb{R}, \mathbb{C} \) | Real and complex numbers |
19+
| \( \mathbb{R}^n \) | \(n\)-dimensional vector space of reals |
20+
| \( \forall x \) | Universal quantifier (“for all \(x\)”) |
21+
| \( \exists x \) | Existential quantifier (“there exists \(x\)”) |
22+
| \( a := b \) | \(a\) is defined as \(b\) |
23+
| \( a =: b \) | \(b\) is defined as \(a\) |
24+
| \( a \propto b \) | \(a\) is proportional to \(b\) (\(a = \text{constant} \cdot b\)) |
25+
| \( g \circ f \) | Function composition (“\(g\) after \(f\)”) |
26+
| \( \Leftrightarrow \) | If and only if |
27+
| \( \Rightarrow \) | Implies |
28+
| \( A, C \) | Sets |
29+
| \( a \in A \) | \(a\) is an element of \(A\) |
30+
| \( \emptyset \) | Empty set |
31+
| \( A \setminus B \) | Elements in \(A\) but not in \(B\) |
32+
| \( D \) | Number of dimensions (\(d = 1, \dots, D\)) | Chapter 8
33+
| \( N \) | Number of data points (\(n = 1, \dots, N\)) | Chapter 8
34+
| \( I_m \) | Identity matrix of size \(m \times m\) |
35+
| \( 0_{m,n} \) | Matrix of zeros of size \(m \times n\) |
36+
| \( 1_{m,n} \) | Matrix of ones of size \(m \times n\) |
37+
| \( e_i \) | Standard (canonical) basis vector (1 in the \(i\)-th position) |
38+
| `dim` | Dimensionality of a vector space |
39+
| `rk(A)` | Rank of matrix \(A\) |
40+
| `Im(Φ)` | Image of a linear mapping \(Φ\) |
41+
| `ker(Φ)` | Kernel (null space) of \(Φ\) |
42+
| `span[b₁]` | Span (generating set) of \(b_1\) |
43+
| `tr(A)` | Trace of \(A\) |
44+
| `det(A)` | Determinant of \(A\) |
45+
| \( | \cdot | \) | Absolute value or determinant (depending on context) |
46+
| \( \| \cdot \| \) | Norm (Euclidean unless stated otherwise) |
47+
| \( \lambda \) | Eigenvalue or Lagrange multiplier |
48+
| \( E_\lambda \) | Eigenspace corresponding to eigenvalue \( \lambda \) |
49+
| \( x \perp y \) | \(x\) and \(y\) are orthogonal |
50+
| \( V \) | Vector space |
51+
| \( V^\perp \) | Orthogonal complement of \(V\) |
52+
| \( \sum_{n=1}^N x_n \) | Sum: \(x_1 + \dots + x_N\) |
53+
| \( \prod_{n=1}^N x_n \) | Product: \(x_1 \cdot \dots \cdot x_N\) |
54+
| \( \theta \) | Parameter vector |
55+
| \( \frac{\partial f}{\partial x} \) | Partial derivative of \(f\) with respect to \(x\) |
56+
| \( \frac{df}{dx} \) | Total derivative of \(f\) with respect to \(x\) |
57+
| \( \nabla \) | Gradient |
58+
| \( f^* = \min_x f(x) \) | Minimum value of \(f\) |
59+
| \( x^* \in \arg\min_x f(x) \) | Value \(x^*\) that minimizes \(f\) |
60+
| \( \mathcal{L} \) | Lagrangian |
61+
| \( \mathcal{L} \) | Negative log-likelihood |
62+
|$\binom{n}{k}$ | Binomial coefficient, $n$ choose $k$|
63+
| \( V_X[x] \) | Variance of \(x\) with respect to the random variable \(X\) |
64+
| \( E_X[x] \) | Expectation of \(x\) with respect to the random variable \(X\) |
65+
| \( \mathrm{Cov}_{X,Y}[x, y] \) | Covariance between \(x\) and \(y\) |
66+
| \( X \perp\!\!\!\perp Y \mid Z \) | \(X\) is conditionally independent of \(Y\) given \(Z\) |
67+
| \( X \sim p \) | Random variable \(X\) is distributed according to \(p\) |
68+
| \( \mathcal{N}(\mu, \Sigma) \) | Gaussian distribution with mean \(\mu\) and covariance \(\Sigma\) |
69+
| \( \mathrm{Ber}(\mu) \) | Bernoulli distribution with parameter \(\mu\) |
70+
| \( \mathrm{Bin}(N, \mu) \) | Binomial distribution with parameters \(N, \mu\) |
71+
| \( \mathrm{Beta}(\alpha, \beta) \) | Beta distribution with parameters \(\alpha, \beta\) |
72+
73+
---
74+
75+
### Table of Abbreviations and Acronyms {-}
76+
77+
| Acronym | Meaning |
78+
|:---------|:---------|
79+
| e.g. | *Exempli gratia* (Latin: “for example”) |
80+
| GMM | Gaussian mixture model |
81+
| i.e. | *Id est* (Latin: “this means”) |
82+
| i.i.d. | Independent, identically distributed |
83+
| MAP | Maximum a posteriori |
84+
| MLE | Maximum likelihood estimation/estimator |
85+
| ONB | Orthonormal basis |
86+
| PCA | Principal component analysis |
87+
| PPCA | Probabilistic principal component analysis |
88+
| REF | Row-echelon form |
89+
| SPD | Symmetric, positive definite |
90+
| SVM | Support vector machine |

01-IntroductionAndMotivation.Rmd

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# Introduction and Motivation
2+
3+
Machine learning focuses on designing algorithms that automatically extract meaningful information from data. A concise and widely accepted definition of machine learning comes from Tom Mitchell (1997):
4+
5+
> “A computer program is said to learn from experience E with respect to
6+
> some class of tasks $T$ and performance measure $P$, if its performance
7+
> at tasks in $T$, as measured by $P$, improves with experience $E$.”
8+
9+
10+
## Finding Words for Intuitions
11+
12+
13+
<div class="definition">
14+
**Machine learning** is the study and development of algorithms that improve automatically through experience and data, without being explicitly programmed for each task.
15+
</div>
16+
17+
Machine learning is a field that combines **data**, **models**, and **learning methods** to identify patterns and make predictions or decisions — ideally generalizing well to new, unseen situations. Data is the foundation — machine learning aims to discover useful patterns from data without relying heavily on domain expertise.
18+
19+
<div class="definition">**Data** are pieces of information collected to describe, measure, or analyze phenomena.
20+
</div>
21+
22+
In practice, data is represented numerically, often as **vectors**, $\mathbf{x} = \begin{bmatrix}x_1\\ x_2\\ \vdots\\ x_N \end{bmatrix}$. Models describe how data is generated or how inputs map to outputs.
23+
24+
<div class="definition">A **model** is a learned representation that maps inputs to outputs based on patterns found in data.
25+
</div>
26+
27+
A model *learns* when its performance improves after processing data. Good models generalize to new, unseen data.
28+
29+
<div class="definition">**Learning** is the process of using data to automatically improve a model’s ability to perform a task.
30+
</div>
31+
32+
The goal is not just to fit the training data, but to perform well on new examples.
33+
34+
35+
36+
Formally, you can think of an algorithm as a mapping from inputs to outputs, where each step is precise, unambiguous, and executable by a computer.
37+
38+
<div class="definition">
39+
An **Algorithm:** is a finite sequence of well-defined instructions or steps designed to solve a specific problem or perform a computation.
40+
</div>
41+
42+
43+
In the context of machine learning, an algorithm provides a systematic procedure for processing data — either to make predictions (as in a predictive algorithm) or to adjust model parameters (as in a training algorithm). In this way, machine learning involves two overlapping meanings of “algorithm”:
44+
45+
1. A **predictor** that makes predictions based on data.
46+
2. A **training procedure** that updates the predictor’s parameters to improve future performance.
47+
48+
Understanding the **mathematical foundations** behind data, models, and learning helps us build, interpret, and improve machine learning systems — and recognize their assumptions and limitations.
49+
50+
51+
52+
## Two Ways to Read This Book
53+
54+
55+
There are two main strategies for learning the mathematics that underpins machine learning.
56+
The **bottom-up approach** builds understanding from fundamental mathematical concepts toward more advanced ideas. This method provides a solid conceptual foundation, ensuring that each new idea rests on well-understood principles. However, for many learners, this approach can feel slow or disconnected from practical motivation, since the relevance of abstract concepts may not be immediately clear.
57+
58+
In contrast, the **top-down approach** begins with real-world problems and drills down to the mathematics required to solve them. This goal-driven strategy keeps motivation high and helps learners understand why each concept matters. The drawback, however, is that the underlying mathematical ideas can remain fragile—readers may learn to use tools effectively without fully grasping their theoretical basis.
59+
60+
Mathematics for Machine Learning is designed to support both approaches — foundational (Part I) and applied (Part II) — so readers can move between mathematics and machine learning freely.
61+
62+
This book is designed to assist readers in their understanding of the textbook Mathematics for Machine Learning. It is more of a foundational approach designed to fill in any gaps a reader might have. In particular, we aim to provide more examples in a less theoretical way. Whether you are reading from a top down or bottom up approach, this book will support your learning.
63+
64+
---
65+
66+
### Part I: Mathematical Foundations
67+
68+
Part I develops the mathematical tools that support all major ML methods — the four pillars of machine learning:
69+
70+
1. **Regression**
71+
2. **Dimensionality Reduction**
72+
3. **Density Estimation**
73+
4. **Classification**
74+
75+
76+
<p align="center">
77+
<img src="Figure1.1MML.png" alt="The Foundations and Four Pillars of Machine Learning" width="400">
78+
</p>
79+
80+
It covers:
81+
82+
- **Linear Algebra (Ch. 2):** Vectors, matrices, and their relationships.
83+
- **Analytic Geometry (Ch. 3):** Similarity and distance between vectors.
84+
- **Matrix Decomposition (Ch. 4):** Interpreting and simplifying data.
85+
- **Vector Calculus (Ch. 5):** Gradients and differentiation.
86+
- **Probability Theory (Ch. 6):** Quantifying uncertainty and noise.
87+
- **Optimization (Ch. 7):** Finding parameters that maximize performance.
88+
89+
---
90+
91+
### Part II: Machine Learning Applications
92+
93+
Part II applies the math from Part I to the four pillars:
94+
95+
- **Ch. 8 — Foundations of ML:** Data, models, and learning; designing robust experiments.
96+
- **Ch. 9 — Regression:** Predicting continuous outcomes using linear and Bayesian approaches.
97+
- **Ch. 10 — Dimensionality Reduction:** Compressing high-dimensional data (e.g., PCA).
98+
- **Ch. 11 — Density Estimation:** Modeling data distributions (e.g., Gaussian mixtures).
99+
- **Ch. 12 — Classification:** Assigning discrete labels (e.g., support vector machines).
100+
101+
---
102+
103+
### Learning Path
104+
105+
Readers are encouraged to mix **bottom-up** and **top-down** learning:
106+
107+
- Build foundational skills when needed.
108+
- Explore applications that connect math to real machine learning systems.
109+
110+
This modular structure makes the book suitable for both **mathematical learners** and **practitioners** aiming to deepen their theoretical understanding.
111+
112+
113+
114+
115+
116+
## Exercises and Feedback
117+
118+
While Mathematics for Machine learning provides some examples and exercises, this book is built to support those who want to practice particular skills or build their knowledge in a particular area. We have added a number of exercises, examples, and videos to hopefully aid your understanding of the material.
119+
120+
121+
122+
123+
### Exercises {.unnumbered .unlisted}
124+
125+
126+
127+
128+
<div class="exercise">
129+
Discuss the ideas of data, models and learning. How are they related?
130+
131+
<div style="text-align: right;">
132+
[Solution](https://youtu.be/YSlIPuSSvaI)
133+
</div>
134+
</div>
135+
136+
137+
<div class="exercise">
138+
In machine learning, how are data typically represented?
139+
140+
<div style="text-align: right;">
141+
[Solution](https://youtu.be/-39cITqPMdk)
142+
</div>
143+
</div>
144+
145+
146+
147+
148+
<div class="exercise">
149+
What is meant by learning in the context of a model?
150+
151+
<div style="text-align: right;">
152+
[Solution](https://youtu.be/4HR3Kkb2Ieg)
153+
</div>
154+
</div>
155+

0 commit comments

Comments
 (0)