Algorithms & ML

Six interactive explanations of algorithms behind machine learning, with figures that run the algorithm in your browser.

Most algorithms here share a skeleton: data goes in, a model transforms it, a prediction comes out, an error signal corrects the model, and a target defines what "correct" means. Figures and equations across the series use these five colors.

The first three build on each other: gradient descent, then backpropagation to get the gradients through a network, then an attention layer trained that way in the page. The other three stand alone. Decision trees have their own series, and PCA applied to simulated expression data, next to t-SNE, is in the bioinformatics series.

Learning by Gradient

Structure and Uncertainty

Learning from Reward

The Vocabulary

What each color stands for, and where it appears:

data
Raw values flowing into the algorithm, what the model sees.
samples in gradient descent · tokens, and the queries, keys and values computed from them, in attention · observations in Bayes · states in RL
model
What the algorithm is learning, the adjustable part.
θ in gradient descent · weights in backprop · WQ, WK, WV in attention · principal axes in PCA · Q-table in RL
prediction
What the model outputs when given data.
ŷ · softmax probabilities and attention weights · projected coordinates · posteriors · Q-values
loss
The error signal, how wrong the prediction was, and the direction to fix it.
∇L in gradient descent · chain-rule gradients in backprop · reconstruction error in PCA · TD-error in RL
target
Ground truth or goal, what "correct" looks like.
labels · the words each word must name in attention · reward/goal in RL · in Bayes the prior plays a loosely similar part, as the starting belief the data revises, but it is an assumption, not a correct answer