Math for ML
The math that actually shows up in machine learning — explained with numpy, code, and the geometric intuition that finally makes it click.
- Chapter 01
Linear Algebra
12 lessons - 01 Why linear algebra matters Data lives in matrices, a model is a function of vectors, and NumPy is just linear algebra you can run. Meet the four operations that almost every…
- 02 Vectors A vector is an arrow in d-dimensional space. Once you see that, similarity, projection, and embeddings all click into place.
- 03 Norms & distances A vector has a direction and a size — and ML constantly needs to measure both: how big is this vector (a norm) and how far apart are two of them (a…
- 04 Matrices as transformations A matrix is two things at once — a table of numbers and a function that warps space. ML leans on both readings constantly.
- 05 Matrix multiplication Element-by-element formulas don't stick. Rows-times-columns and shape arithmetic do. Here's how matmul actually works in ML code.
- 06 Tensor operations Scalars, vectors, and matrices generalize to tensors — n-dimensional arrays — and every ML framework is, underneath, a tensor library. A neural net…
- 07 Linear systems & RREF Almost every closed-form model fit is a linear system in disguise. Gaussian elimination is the algorithm that solves it — and tells you whether a u…
- 08 Rank, independence & basis When does a feature add real information, and when is it just a copy of the others? Span, independence, basis, and rank are the four ideas that ans…
- 09 Orthogonality & least squares You can't fit noisy data exactly — so you get as close as possible. "As close as possible" is a projection, and the magic is that the leftover erro…
- 10 Eigenvalues & eigenvectors Some directions a matrix only stretches — it doesn't rotate them. Those directions are the secret structure inside data, covariance, and PageRank.
- 11 Singular Value Decomposition Every matrix — any shape, any contents — factors into a rotation, a stretch, and another rotation. That single fact powers PCA, recommender systems…
- 12 PCA from scratch Dimensionality reduction in five lines. Center, covariance, eigendecompose, project. Then plot your 50-dim data in 2D.
- Chapter 02
Calculus & Optimization
7 lessons - 13 Derivatives & tangents Derivatives tell you which way to move and how far. That's everything gradient descent needs. Here's the calculus you actually use, no textbook pro…
- 14 Partial derivatives When a loss has many parameters, you take a derivative with respect to each one. Stack them into a vector and you have the gradient — the heart of…
- 15 Gradient descent Every neural net is trained by walking downhill on a loss surface. Here's how that walk actually works.
- 16 Backpropagation foundations Backprop is not a new algorithm. It's the chain rule applied to a graph, computed in the right order. Here it is on a tiny network, by hand.
- 17 Jacobian, Hessian & Taylor Gradient descent only uses the slope. But every loss surface also has curvature — and the Jacobian, the Hessian, and the Taylor expansion are how y…
- 18 Convexity "Convex loss" is the quiet reason classical ML just works and deep nets need babysitting. Convexity is the guarantee that downhill always leads hom…
- 19 Lagrange multipliers Most ML optimization comes with strings attached — keep the weights small, keep the probabilities summing to one, classify everything correctly. La…
- Chapter 03
Probability & Statistics
15 lessons - 20 What is probability A random variable, the rules of probability, independence, conditioning, expectations. The ideas behind every classifier output and every A/B test.
- 21 Bayes theorem A formula for updating your beliefs when new evidence arrives. Powers spam filters, A/B testing, and a chunk of modern AI.
- 22 Distributions you should know Bernoulli, Binomial, Uniform, Normal, Exponential. Each one models a different real-world situation. Sample from them, plot them, recognize them in…
- 23 Sampling methods Two recurring needs in ML: draw samples from a distribution, or estimate an expectation you can't integrate. Monte Carlo, inverse-transform, reject…
- 24 Stochastic processes A random variable is one random number; a stochastic process is a whole sequence of them indexed by time — a random function. Markov chains, statio…
- 25 Covariance & correlation Variance measures how one feature spreads; covariance measures how two move together; correlation puts it on a clean −1 to 1 scale. Pack them into…
- 26 The multivariate Gaussian The bell curve, generalized to many dimensions — and the most important distribution in all of ML. A mean vector and a covariance matrix describe i…
- 27 Central limit theorem Average enough independent samples — from ANY distribution — and the result is normal. This is the proof behind the bell curve's ubiquity, and the…
- 28 Estimation & confidence intervals You never see the true parameter — only an estimate from a finite sample. Estimators, standard error, and confidence intervals are how you say how…
- 29 Hypothesis testing H₀, p-values, t-tests — what they actually mean, when to use them, and why a 'significant' result isn't proof. The grammar of turning 'is this diff…
- 30 A/B testing H0, H1, p-values, sample size, the two-proportion z-test. The applied statistics every data scientist and PM runs — without the textbook fog.
- 31 Maximum likelihood & MAP Why is the loss for regression squared error, and for classification cross-entropy? Both fall out of one principle — maximum likelihood — and addin…
- 32 Entropy & information theory Entropy measures surprise — the floor on how many bits it takes to encode outcomes. From it flow cross-entropy (your classification loss), KL diver…
- 33 KL Divergence How far is one probability distribution from another? KL divergence answers that — it is the engine behind cross-entropy loss, VAEs, distillation,…
- 34 Simpson's Paradox A trend that holds in every subgroup can reverse when the groups are combined. The cause is always a lurking variable — and missing it flips your c…
- Chapter 04
Numerical & Applied Math
3 lessons - 35 Numerical stability On paper, math is exact. On a computer it runs in finite-precision floating point, where exp(1000) is infinity, log(0) is minus-infinity, and a tho…
- 36 The Fourier transform Any signal is a sum of sine waves of different frequencies. The Fourier transform converts between the time domain (the wave) and the frequency dom…
- 37 Graph theory A graph is things plus the relationships between them — nodes and edges. It's where discrete structure meets linear algebra: the adjacency matrix t…
- End of section 0 / 37 complete
Make it stick — pass every quiz.
Each lesson has a short quiz at the bottom. Passing the quiz is what marks the lesson complete and counts toward your certificate.
Math for ML — frequently asked questions
Straight answers to the questions people ask most about math for ml.
How much math do I really need for machine learning?
Enough to reason, not to derive everything from scratch: linear algebra (vectors, matrices, dot products), the basics of calculus (gradients and the chain rule), and probability and statistics (distributions, expectation, Bayes). You can start applying models with less and deepen the math as you go.
Why is linear algebra so important for ML?
Data is represented as vectors and matrices, and nearly every model — from linear regression to neural networks — is built on matrix multiplication. Linear algebra is the language that makes these operations fast and lets you reason about transformations, projections, and dimensionality.
What is a gradient, intuitively?
A gradient is the vector of partial derivatives that points in the direction of steepest increase of a function. Training follows the negative gradient downhill to reduce the loss — that's gradient descent — and the gradient's size tells you how steep the slope is at the current point.
What's the difference between probability and statistics?
Probability reasons forward — given a known model, how likely is an outcome. Statistics reasons backward — given observed data, what model or parameters likely produced it. ML uses both: probability to define models, statistics to fit and evaluate them.
What is Bayes' theorem used for?
Bayes' theorem updates a prior belief into a posterior after seeing evidence, by weighing how likely the evidence is under each hypothesis. It underpins spam filters and medical-test interpretation, and it explains why a positive result on a rare-condition test can still mean low actual risk.