Visual, executable learning guides

Machine learning from scratch

Build core algorithms from their equations with compact, tested NumPy examples. Every guide connects its visual explanation to the official Machine Learning Refined chapter, notebook, exercises, and source repository.

Where to start

You will need basic Python, NumPy arrays, and some familiarity with derivatives. Start with gradient descent to understand parameter updates, then use logistic regression to fit a two-class model. Choose K-means to explore grouping samples without labels. Each guide includes runnable code, expected output, parameter choices, and an experiment you can try.

For the full mathematical treatment, browse the book chapters and exercises. To explore the companion animations and run source notebooks, open the Python notebook workbench.

Normalized gradient descent steps moving across objective contours toward a minimum

Chapter 3 / Introductory

Gradient Descent from Scratch in Python

Understand the gradient descent update rule, implement it with NumPy, and see how step size changes convergence.

Read the guide
Logistic regression decision boundary changing as a two-class model is fitted

Chapter 6 / Introductory

Logistic Regression from Scratch in Python

Build binary logistic regression with NumPy from the sigmoid, cross-entropy loss, and gradient update.

Read the guide
K-means points changing cluster assignments as centroids move

Chapter 8 / Introductory

K-Means Clustering from Scratch in Python

Implement K-means clustering with NumPy by alternating nearest-centroid assignments and centroid updates.

Read the guide