Diagramium
📈 Narrated diagram

How a machine learning model is trained

The real pipeline behind a working model — collecting and cleaning data, splitting it honestly, training, tuning, testing, deploying and watching for drift.

16 steps3 min readNarrated with a studio voice
How a machine learning model is trainedyesadjust and train againnoyesThe trigger that begins the processA question worth predictingInformation going in or coming out of a stepCollect the raw dataA step — work that gets doneLabel the examplesA step — work that gets doneClean out the messA step — work that gets doneBuild the featuresA step — work that gets doneSplit into three setsA step — work that gets doneChoose a modelA step — work that gets doneTrain on the training setA step — work that gets doneScore the validation setA branch — the path splits on a conditionOverfitting?A step — work that gets doneTune the hyperparametersA step — work that gets doneOne run on the test setA step — work that gets doneDeploy behind an APIA step — work that gets doneWatch it in productionA branch — the path splits on a conditionHas the data drifted?A stadium shape that finishes the processThe loop starts again
How a machine learning model is trained — the complete diagram. Press Present to watch it build itself.
Step 1 of 16

A question worth predicting

Machine learning does not begin with code. It begins with a question you can actually score. Will this customer cancel? Is this scan showing a tumour? If nobody can say whether an answer was right, there is nothing here to learn from.

Step 2 of 16

Collect the raw data

Now go and gather examples, thousands of them. Teams routinely spend most of a project right here, and the uncomfortable truth of the field is that more and better data usually beats a cleverer algorithm.

Step 3 of 16

Label the examples

Someone has to say what the correct answer was. Labelling a hundred thousand images costs real money and months of human attention, and every disagreement between two labellers quietly sets a ceiling on how good the model can ever be.

Step 4 of 16

Clean out the mess

Real data is filthy. Missing values, duplicated rows, dates written three different ways, a body temperature recorded as minus nine hundred and ninety nine. Left alone, every one of those teaches the model something confidently and permanently wrong.

Step 5 of 16

Build the features

Feature engineering turns raw columns into signal. A date of birth is nearly useless to a model; the age it implies is not. One well chosen feature often lifts accuracy more than a whole month of fiddling with the model.

Step 6 of 16

Split into three sets

Before any training, carve the data into three parts, commonly eighty, ten and ten. The training set teaches, the validation set guides your choices, and the test set is locked in a drawer and not opened until the very end.

Step 7 of 16

Choose a model

Pick the simplest thing that might work. For tables of numbers, gradient boosted trees still win most competitions; for images and language, neural networks. Starting simple gives you a baseline that everything fancier has to beat.

Step 8 of 16

Train on the training set

Training is a loop. Predict, measure the error, nudge the parameters, repeat. It might run for two minutes on a laptop or for six weeks across thousands of graphics cards, but the loop itself is exactly the same shape.

Step 9 of 16

Score the validation set

Now score the model on data it has never seen. The gap between training accuracy and validation accuracy is the single most informative number in the entire project, and experienced people look at it before anything else.

Step 10 of 16

Overfitting?

If it is brilliant on training data and merely average on validation data, it memorised rather than learned. Researchers demonstrating this trained a husky and wolf classifier that scored well by ignoring the animals entirely and simply checking whether there was snow in the background.

Step 11 of 16

Tune the hyperparameters

Hyperparameters are the dials you set before training starts. Tree depth, learning rate, how hard to penalise complexity. Search them properly with cross validation rather than by hand, then train again and see whether the gap has closed.

Step 12 of 16

One run on the test set

The test set is used exactly once. Peek at it repeatedly and you begin tuning to it as well, and your honest estimate of real world performance quietly evaporates without anybody noticing it has gone.

Step 13 of 16

Deploy behind an API

Now the genuinely hard part. The model has to answer in milliseconds, compute its features exactly the way the training pipeline did, and fail gracefully. Most models that die in production die of a mismatch between those two pipelines.

Step 14 of 16

Watch it in production

Watch latency, watch errors, and watch the shape of the incoming data. Watch what the predictions do to the world as well, because a model that recommends products starts changing the very behaviour it is trying to predict.

Step 15 of 16

Has the data drifted?

The world keeps moving. Prices rise, fashions turn, a pandemic arrives, and a model trained on last year's reality slowly stops working. That slide is called drift, and it is completely silent unless you measure it deliberately.

Step 16 of 16

The loop starts again

So a trained model is never really finished. It is a loop that keeps turning, with fresh data, fresh labels and fresh training runs, for as long as anyone out there still depends on the answer.

Watch it explain itself

Every step above is narrated aloud. Play it, or open it in the editor and make it yours — no account needed.