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.
-
L0
Start here
-
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.
-
-
L1
Data & intuition
-
Lesson 2 · About 10 min
Data as numbersA 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.
-
Lesson 3 · About 12 min
Centre and spreadTwo numbers can sum up a set of values: where they sit, and how far they spread.
-
Lesson 4 · About 12 min
Measuring errorEvery model misses. A loss sums up all the misses in one number.
-
Lesson 5 · About 10 min
Slopes and derivativesA slope says how steep a curve is at one point, and which way is downhill.
-
-
L2
Learning from data
-
Lesson 6 · About 12 min
Linear regressionLeast squares chooses the straight line with the smallest total squared error.
-
Lesson 7 · About 12 min
Gradient descentGradient descent finds the bottom of a loss by taking small steps downhill, again and again.
-
Lesson 8 · About 12 min
Many features and the loss surfaceWith two numbers to learn, the loss becomes a surface. Its shape decides how easily gradient descent finds the bottom.
-
Lesson 9 · About 10 min
Train, validate, testA model is only useful if it works on data it has not seen. Here is how to measure that honestly.
-
Lesson 10 · About 12 min
Overfitting and regularisationA model can be too simple or too flexible. Both do badly on new data, for different reasons.
-
-
L3
Classic ML
-
Lesson 11 · About 10 min
k-nearest neighboursTo label a new case, look at the cases most like it and let them vote.
-
Lesson 12 · About 12 min
Logistic regressionSquash a straight-line score into a probability, then pick a threshold to turn it into a class.
-
Lesson 13 · About 12 min
Naive BayesDescribe each class on its own, then let Bayes' rule say which class a new case most likely came from.
-
Lesson 14 · About 12 min
Support vector machinesOf all the straight lines that split two classes, pick the one with the widest empty street around it.
-
Lesson 15 · About 10 min
Decision treesLabel a case by asking it a few yes/no questions, each one chosen to sort the classes apart as well as it can.
-
Lesson 16 · About 10 min
Bagging and random forestsOne 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.
-
Lesson 17 · About 12 min
Gradient boostingAdd small trees one at a time, each fitted to what the model still gets wrong.
-
Lesson 18 · About 10 min
k-means clusteringWith no labels at all, find groups by moving a few centres until they settle.
-
Lesson 19 · About 12 min
Principal component analysisFind the direction in which the data vary most, and keep most of the information with fewer numbers.
-
-
L4
Deep learning
-
Lesson 20 · About 10 min
The artificial neuronA weighted sum, a bias and a squashing curve: the building block of every neural network, and an old friend in disguise.
-
Lesson 21 · About 11 min
Hidden layers: bending the boundaryPress Train and watch a small network bend its boundary, step by step, around data that no straight line can split.
-
Lesson 22 · About 12 min
BackpropagationHow did the network know which way to nudge each weight? Follow every number through a tiny network, forward and then backward.
-
Lesson 23 · About 11 min
Training a networkThe craft of running training: small batches, passes through the data, and how to notice when a network starts memorising.
-
Lesson 24 · About 11 min
Optimisers: momentum and AdamPlain 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.
-
Lesson 25 · About 10 min
Going deeper: vanishing gradientsStack 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.
-
Lesson 26 · About 10 min
ConvolutionsA 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.
-
Lesson 27 · About 11 min
Convolutional networksStack 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.
-
Lesson 28 · About 11 min
Recurrent networksA 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.
-
-
L5
Modern AI
-
Lesson 29 · About 9 min
Tokens: text as numbersA 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.
-
Lesson 30 · About 10 min
Embeddings: words as pointsAn 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.
-
Lesson 31 · About 10 min
Predicting the next tokenA 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.
-
Lesson 32 · About 11 min
AttentionAttention 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.
-
Lesson 33 · About 10 min
TransformersA 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.
-
Lesson 34 · About 12 min
Large language models, in miniatureMost 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.
-
Lesson 35 · About 10 min
Generative modelsA 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.
-
Lesson 36 · About 12 min
Diffusion: from noise to dataAdd 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.
-
-
L6
In practice
Evaluation, calibration, interpretability, fairness
Coming next