Machine Learning Math Lab

The math machine learning runs on, made hands-on. Drag the dots, move the sliders, and watch the formulas do what they describe. Pick a topic to begin.

Drag the start dot anywhere on the surface. Then press Step, or Run to animate.

Rolling downhill

θ θ α · ∇L(θ)

Training a model means finding the settings (θ) that make its error (L) as small as possible. The error forms a landscape. Gradient descent just walks downhill: the gradient ∇L points to the steepest way up, so we step the opposite way. α is the learning rate, the size of each step.

Try a tiny α (slow crawl) and a large one (it overshoots and can fly off). Then stretch the bowl and watch the path zig-zag, the reason ill-shaped error surfaces are slow to train.

0.10
1.0×
Step0
Error L--
Position--
Statusready
Learn it step by step Step 1 of 6

What "training" actually means

A model is a machine with a set of dials, called parameters and written θ. Different dial settings make different predictions, and some settings are better than others.

We score "better" with a single number, the error or loss (written L): how wrong the model is on our data. Training is just the hunt for the dials that make L as small as possible.

About this lab

Everything here runs locally in your browser, with no data leaving the page. It is built for intuition first: the goal is to feel why each idea works before meeting its notation. These four pieces, optimization, linear algebra, calculus, and probability, are the load-bearing math under nearly every machine learning system. Once they feel natural, the rest of the field reads like applications of them.