CHAPTER 25 / 40
Python for ML: Code the Math
8 lessons · Explore, experiment and understand.
Let’s figure it out.
Ask me about this course or where to start.
Every lesson is a runnable Python notebook in your browser — NumPy implementations of vectors, SVD, gradient descent, linear regression and PCA, each linked back to the math chapter it came from.
- NumPy
- Pyodide in-browser
- PCA from scratch
- linear regression from scratch
- Step 104~20m1Code · 56⚡Challenge
Python and NumPy for ML
Set up Python, meet NumPy, and learn the one rule that makes machine-learning code fast: vectorize everything. Every cell in this chapter ru…
Open lesson - Step 105~15m2Code · 45⚡Challenge
Vectors and Matrices in NumPy
From the math: vectors, dot products, matrix-vector products, and angles between vectors — implemented as one-line NumPy expressions. Links…
Open lesson - Step 106~15m2Code · 35⚡Challenge
Solving Linear Systems
Solve Ax = b the right way (`np.linalg.solve`) and the wrong way (`inv(A) @ b`) — and learn why one is numerically stable and the other isn'…
Open lesson - Step 107~15m3D · 3Code · 34★Most cinematic
Eigenvalues, SVD, and Matrix Decompositions
Compute eigenvalues and SVD in three lines, then use SVD to build a rank-k image compressor. Links to Chapter 4 (Matrix Decompositions) and…
Open lesson - Step 108~20m3D · 12Code · 55★Most cinematic⚡Challenge
Gradients and Autodiff
Compute gradients three ways — analytically, numerically (finite differences), and automatically (autodiff intuition) — and learn why the au…
Open lesson - Step 109~15m3D · 12Code · 34★Most cinematic
Implementing Gradient Descent
Code gradient descent from scratch on a quadratic, then build SGD and momentum versions. Watch what learning rate does — too small crawls, t…
Open lesson - Step 110~15m2Code · 44
Linear Regression from Scratch
Implement linear regression three ways — closed-form normal equations, gradient descent, and SVD-based pseudoinverse — and prove they agree…
Open lesson - Step 111~20m3D · 3Code · 45★Most cinematic⚡Challenge
PCA from Scratch
Implement PCA in 10 lines: center the data, do SVD, project onto top-k axes. Verify with sklearn. Links to Chapter 10 (PCA) and Chapter 4 (M…
Open lesson