Two numbers per message, one line, and 96.8% of them sorted right.
How long it is, and how many digits it has. That is everything this model knows, which means the whole of it fits on a page and you can watch it train. Six real messages, and you say how sure it will be about each one.
- Score
- 0
- Exact
- 0
- Streak
- ×0
- Message
- 1/6
Say how likely a trained filter is to call this message spam.A trained spam filter is about to score the message below, and the only two things it looks at are printed underneath it. Say how likely you think it is to call this one spam.
A message it has not seen
You have won a Nokia 7250i. This is what you get when you win our FREE auction. To take part send Nokia to 86021 now. HG/Suite342/2Lands Row/W1JHL 16+
150 characters · 16 digits. That is everything the model gets.
99.5% is what it gives this one
It really was spam. The model called it correctly.
Every held-out message, placed by two numbers you can read off it yourself: how long it is, and how many digits it contains. Spam is mostly up and to the right. Nothing has been trained yet.
Loading the measurements…
A classifier draws a line, then measures how far you are from it.
NextTwenty questions+What is actually going onWhy put the answer through a curve at all?Because a probability has to sit between nought and one, and a straight line does not.
The line gives a number that runs off to infinity in both directions, which is fine for saying which side you are on and useless as a probability. The logistic curve squashes that whole range into nought to one, steeply near the boundary and almost flat far from it.
That shape is doing something honest. A message far into spam territory does not become twice as spam if you double its distance; it is already as certain as the model can be. The flattening is the model refusing to overstate.
It also gives training something to work with. Hastie and colleagues set out why these models are fitted by likelihood rather than squared error: with the curve in place, being confidently wrong costs enormously more than being unsure, which is the incentive you want.
+What is actually going onIs a straight boundary not a serious limitation?Yes, and it is a good default anyway. Most of the value in a model is usually in the features, not the shape of its boundary.
A straight line cannot capture a rule like “spam is either very short or very long”. Feed it that pattern and it will fail, and no amount of training fixes it.
The usual answer is not a fancier model but a better feature. Add a column for how far the length is from typical and the same straight line handles it, which is the first module of this track arriving again from a different direction.
Zinkevich’s advice from inside Google is worth repeating here: start with something simple, get the plumbing right, and prefer a model whose mistakes you can look at. This one you can literally look at.
+Go and try this for realPlot two features and look
Go and try this
Plot two features and look
Take any two-column prediction problem near you and plot it: one feature across, one up, and colour by the answer. Five minutes in a spreadsheet is enough.
Then ask whether the picture supports the model somebody wants to build on it.
What to watch for: Whether a straight line could separate the two colours at all. If it obviously could not, that is a feature problem, and reaching for a bigger model first will hide it rather than fix it.
+Check yourselfIt marks itself, and nothing is sent anywhere.
Match each part of the model to what it does.
Tap one from the pool, then tap the row it belongs to.
- The weights
- The bias
- The logistic curve
- The threshold
The digit weight came out at 3.47 and the length weight at 0.30. What does that tell you?
Sources
- SMS Spam Collection v.1
Almeida, Gómez Hidalgo & Yamakami
Every dot and every message on this page, split 80/20 with the same seed the rest of the site uses.
Free to use with attribution to the authors' 2011 paper
- The Elements of Statistical Learning, second edition
Hastie, Tibshirani & Friedman (Springer, 2009)
Chapter 4 on logistic regression: the linear boundary, the logistic function that turns distance into probability, and why it is fitted by likelihood rather than by squared error.
- Rules of Machine Learning: Best Practices for ML Engineering
Martin Zinkevich, Google
The advice this page ends on: start with a simple model you can inspect, and be sure the plumbing works before reaching for anything cleverer.