Skip to the content
ML Explorer Reju Sam John

Machine learning, one idea at a time

ML Explorer

How machine learning works, for students and complete beginners: from what a model is to fitting one, testing it fairly and keeping it from overfitting, and on to the classic methods: nearest neighbours, trees and forests, clustering and PCA, then neural networks.

Each lesson shows one idea on a single picture, in a few short steps. Move the controls and watch what changes. Every number in the pictures is computed in your browser from the lesson’s data as you go.

The main text needs no maths. The formulas, and the reasons behind them, sit one click deeper under “The maths”.

The path

Each lesson builds on the ones before it. L0 to L5 are ready; L6 is coming next. Your progress is kept in this browser only.

  1. L0

    Start here

    1. Lesson 1 · About 8 min

      What is a model?

      A model is a rule learned from examples. Once it has learned, it can make a guess about a case it has never seen.

  2. L1

    Data & intuition

    1. Lesson 2 · About 10 min

      Data as numbers

      A model only ever sees numbers. Each example becomes a short list of numbers, a vector, which is also a point you can draw and measure.

    2. Lesson 3 · About 12 min

      Centre and spread

      Two numbers can sum up a set of values: where they sit, and how far they spread.

    3. Lesson 4 · About 12 min

      Measuring error

      Every model misses. A loss sums up all the misses in one number.

    4. Lesson 5 · About 10 min

      Slopes and derivatives

      A slope says how steep a curve is at one point, and which way is downhill.

  3. L2

    Learning from data

    1. Lesson 6 · About 12 min

      Linear regression

      Least squares chooses the straight line with the smallest total squared error.

    2. Lesson 7 · About 12 min

      Gradient descent

      Gradient descent finds the bottom of a loss by taking small steps downhill, again and again.

    3. Lesson 8 · About 12 min

      Many features and the loss surface

      With two numbers to learn, the loss becomes a surface. Its shape decides how easily gradient descent finds the bottom.

    4. Lesson 9 · About 10 min

      Train, validate, test

      A model is only useful if it works on data it has not seen. Here is how to measure that honestly.

    5. Lesson 10 · About 12 min

      Overfitting and regularisation

      A model can be too simple or too flexible. Both do badly on new data, for different reasons.

  4. L3

    Classic ML

    1. Lesson 11 · About 10 min

      k-nearest neighbours

      To label a new case, look at the cases most like it and let them vote.

    2. Lesson 12 · About 12 min

      Logistic regression

      Squash a straight-line score into a probability, then pick a threshold to turn it into a class.

    3. Lesson 13 · About 12 min

      Naive Bayes

      Describe each class on its own, then let Bayes' rule say which class a new case most likely came from.

    4. Lesson 14 · About 12 min

      Support vector machines

      Of all the straight lines that split two classes, pick the one with the widest empty street around it.

    5. Lesson 15 · About 10 min

      Decision trees

      Label a case by asking it a few yes/no questions, each one chosen to sort the classes apart as well as it can.

    6. Lesson 16 · About 10 min

      Bagging and random forests

      One tree is jumpy. Many trees, each grown on its own sample of the data, voting together, are steadier, and the rows each tree never saw give you a test score for free.

    7. Lesson 17 · About 12 min

      Gradient boosting

      Add small trees one at a time, each fitted to what the model still gets wrong.

    8. Lesson 18 · About 10 min

      k-means clustering

      With no labels at all, find groups by moving a few centres until they settle.

    9. Lesson 19 · About 12 min

      Principal component analysis

      Find the direction in which the data vary most, and keep most of the information with fewer numbers.

  5. L4

    Deep learning

    1. Lesson 20 · About 10 min

      The artificial neuron

      A weighted sum, a bias and a squashing curve: the building block of every neural network, and an old friend in disguise.

    2. Lesson 21 · About 11 min

      Hidden layers: bending the boundary

      Press Train and watch a small network bend its boundary, step by step, around data that no straight line can split.

    3. Lesson 22 · About 12 min

      Backpropagation

      How did the network know which way to nudge each weight? Follow every number through a tiny network, forward and then backward.

    4. Lesson 23 · About 11 min

      Training a network

      The craft of running training: small batches, passes through the data, and how to notice when a network starts memorising.

    5. Lesson 24 · About 11 min

      Optimisers: momentum and Adam

      Plain gradient descent zig-zags down a narrow valley. Momentum, RMSProp and Adam change how each step is made; here you race them, then try them on a real network.

    6. Lesson 25 · About 10 min

      Going deeper: vanishing gradients

      Stack ten hidden layers of sigmoid units and the gradient that reaches the first layer can be millions of times smaller than at the last. Here you measure it layer by layer, see why, and watch a ReLU network with better starting weights train where the sigmoid one stalls.

    7. Lesson 26 · About 10 min

      Convolutions

      A filter is a small grid of weights slid across an image. At each position it multiplies the pixels under it by its weights and adds them up, giving one number, large where the patch looks like the filter. The same nine weights are used everywhere.

    8. Lesson 27 · About 11 min

      Convolutional networks

      Stack a convolution, a ReLU and a pooling step, put one output unit on top, and let training choose the filters. With weights shared across the image, the whole network needs far fewer of them than a dense one.

    9. Lesson 28 · About 11 min

      Recurrent networks

      A recurrent network reads a sequence one step at a time and carries a hidden state forward. Train one live to repeat the bit it saw a few steps ago, and see why reaching further back is harder.

  6. L5

    Modern AI

    1. Lesson 29 · About 9 min

      Tokens: text as numbers

      A model reads text as a list of numbers. Watch a tokeniser build its vocabulary by merging the commonest pair of pieces, again and again, and type a sentence of your own to see it split.

    2. Lesson 30 · About 10 min

      Embeddings: words as points

      An embedding is a short list of numbers for each word, learned from text. Train one live and watch words that are used in the same way end up pointing the same way.

    3. Lesson 31 · About 10 min

      Predicting the next token

      A language model does one job: given the text so far, it gives a probability to every possible next token. Build one from counts, type a few letters to see its guesses, and make it write.

    4. Lesson 32 · About 11 min

      Attention

      Attention lets every position in a sequence look straight back at any earlier one. Drag a query and watch the weights shift, then train a small attention model live on the task a recurrent network found hard.

    5. Lesson 33 · About 10 min

      Transformers

      A transformer block is attention plus a small network, each wrapped in a shortcut and layer normalisation. Build one, train it live to reverse eight digits, and watch its attention maps turn into a mirror image.

    6. Lesson 34 · About 12 min

      Large language models, in miniature

      Most large language models today are transformers trained to predict the next token on a very large amount of text. Train a tiny one here, live, watch its writing go from noise to words, and then check how many of the sentences it writes are true.

    7. Lesson 35 · About 10 min

      Generative models

      A generative model learns where the data falls, as a probability distribution, and then makes new data by sampling from it. Fit one live with EM and press Sample.

    8. Lesson 36 · About 12 min

      Diffusion: from noise to data

      Add noise to a spiral, step by step, until almost nothing of it is left. Train a small network to guess that noise. Then start from pure noise, take the guesses back out step by step, and watch 400 points walk back into a spiral.

  7. L6

    In practice

    Evaluation, calibration, interpretability, fairness

    Coming next