Cascade Insights ยท AI explainer series
How machine learning works, shown on a spam filter you can train yourself
is a way of building software where nobody writes the rules. A computer gets examples with the right answers attached and works out a rule on its own. It guesses, checks how wrong the guess was, and adjusts a little. Then it does that again, many times over. This page runs that loop for real on 40 emails, so you can watch a spam filter learn its rule as it happens.
New to the vocabulary? Tap any dotted term for a definition, or .
1 · Training
The examples a machine learns from are its . Here, each dot is one email. Two set its position: how many links it has (left to right) and how many ALL-CAPS words or exclamation marks it has (bottom to top). Its color is the a person gave it, the the model gets scored against. The is the dark line, and anything on the shaded side gets called spam.
The line starts in a bad spot: 25 of 40 emails are on the wrong side. Press Train, or Step through one pass at a time.
Real models adjust thousands to trillions of dials, not two. The loop is the same: guess, get scored, nudge.
The two dials here are the line's tilt and its position. Each nudge turns both of them a little.
The line sorts every training email. The ones that land on the wrong side pulse.
The adds up how wrong the line was, and a confident mistake counts for more than a near-miss. The meter on the edge shows a simpler version, a count of wrong emails.
The points the way to tilt and shift the line so it's less wrong, and the sets the size of the step. One full round through the emails is an .
Two emails stay on the wrong side however long you train. One is a friend's excited note full of links and caps. The other is a quiet spam with almost nothing to give it away. A straight line can't separate either from its neighbors, so training settles on the best compromise it can find. Section 3 shows what happens when the line is allowed to bend.
2 · Using the model
Once training stops, the line is frozen. Press New email arrives above and a message the model has never seen drops onto the plot. The model sorts it by which side of the line it lands on, and nothing gets nudged. Using a trained model this way is called . It's what happens every time anyone uses machine learning, whether that's a spam filter sorting mail or a chatbot answering a question.
After each sort, the card shows who actually sent the email. Watch the third one. It's from a friend, and the model makes the same mistake it made in training.
3 · Testing the model
Give the more freedom and it can bend around the emails it gets wrong. Push the slider far enough and it gets every training email right, which looks like progress. To check, machine learning teams keep some examples out of training on purpose and test the model on them afterward. Those examples are a .
What this shows, and only thisOne very flexible boundary, 40 training emails and 16 held back. The squiggle gets every training email right and does worse on the new ones. It learned the positions of these particular emails and not much about spam, so it stopped . That gap between the two scores is called . Real teams test on held-out data to catch it, which is the point of this demo. It doesn't show that they fail to.
The mistakes also come in two kinds, and the straight line makes one of each.
The model said spam and it wasn't. Lots of links and exclamation marks, from someone you wanted to hear from. .
The model said it was fine and it wasn't. A quiet message with a couple of links, asking for payment details. .
The two mistakes don't cost the same: a spam that slips through wastes a few seconds, while a client's email buried in spam can cost a deal, so where to draw the line depends on which one hurts more.
4 · Scaling up
Large language models like ChatGPT and Claude are machine learning too, trained with this same loop. Each example is a stretch of text with the next word hidden, and the label is the word that actually came next. The text supplies its own answers, so nobody has to label it by hand.
"Can we move the meeting to ___"
Illustrative numbers. A real model scores tens of thousands of possible words at once, and each "word" is actually a . For what tokens are, see How AI Breaks Text into Tokens; for how a model picks from these odds once training is done, see Why AI Never Gives the Same Answer Twice.
Scale is given in orders of magnitude on purpose. Exact figures change with every model generation, and most labs don't publish them.
This stage is called . Like the spam line, the model is frozen when it ends. Chatting with it is inference, and the dials stay where training left them.
It skips what happens inside a neural network, learning from rewards instead of labels, finding patterns in data nobody labeled, the fine-tuning that shapes a chatbot's manners after pretraining, and the math of precision and recall. Each of those would need its own page, and none of them replaces the basic loop.
A model only knows the examples it saw. If your customers, products or email look different from its , expect the line to sit in the wrong place for you.
A score on training data says little. Ask for results on a and how much that set looks like your own work.
A single number hides the split between false positives and false negatives. Ask for both.
Spammers change tactics while the line stays where training left it. That slow slide in accuracy is , and the fix is retraining on fresh examples.