The word “free” is beaten by how long the message is.
Everybody picks the word. On 5,574 real text messages, asking whether the message runs past 120 characters separates spam from ordinary post nearly three times better, and it never looks at a single word. Put money on a few of these before you are shown the counts.
- Score
- 0
- Right
- 0
- Streak
- ×0
- Pair
- 1/6
You are choosing what a spam filter gets to look at. One of these two clues separates spam from ordinary messages better than the other. Call it, then both get measured on real messages.
Which of these tells you more about whether a message is spam?
Here is every training message in one bar. Pink is spam, blue is ordinary, and about one in seven is pink. A model cannot read any of them. Somebody has to turn each message into answers to questions, and those answers are all it will ever see.
Loading the corpus…
A model sees your features, never your data.
NextTrain and test+What is actually going onWhat is a bit, and why measure in those?It is one perfect yes-or-no answer. Bits removed says how much of the guessing a feature saves you.
Before you know anything, one message in seven is spam, and Shannon gives that uncertainty a size: 0.567 of a bit. If you could ask one question whose answer told you the label outright, it would remove all of it. Real questions remove a fraction.
That is why bits are the right unit for choosing features. Counting how much spam a feature catches rewards a feature that fires on everything. Counting how pure its pile is rewards one that fires almost never. Bits removed balances both, because it weighs each pile by how big it is.
The same measure, applied over and over, is how a decision tree picks what to ask next. That is a later module, and it is not a new idea when you get there.
+What is actually going onWhy is this where the work is, rather than the algorithm?Because no algorithm can recover what the features left out.
A model sees a row of numbers. If the thing that actually explains your problem is not in that row, no amount of tuning invents it, and the effort goes into squeezing tenths of a per cent out of a set of columns that were never going to answer the question.
Zinkevich’s account of this from inside Google is blunt about the ordering: get the features right first, and prefer a simple model on good features to a clever one on poor features. It is the least glamorous part of the subject and the part that decides whether the rest of it was worth doing.
It is also where the ethics live. Choosing what to record is choosing what the system can ever take into account, and what it will be structurally blind to.
+Go and try this for realWrite down the row
Go and try this
Write down the row
Take a prediction somebody in your work would like to have. Write down the label first, in one line: the exact thing you want to know before it happens.
Then write the row of features you could put in front of it, using only things that exist at the moment the prediction is needed.
What to watch for: How many of your columns you would actually have at the moment you need the prediction. The ones you would not are leaks, and they are the reason a model can test beautifully and fail in production.
+Check yourselfIt marks itself, and nothing is sent anywhere.
You are building a model to predict which customers cancel. Which pile does each column belong in?
Tap an item, then tap where it belongs. Dragging works too.
The word free removed 0.063 bits. Message length removed 0.167. What does that tell you?
Sources
- SMS Spam Collection v.1
Almeida, Gómez Hidalgo & Yamakami
All 5,574 real messages behind every count 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
- Contributions to the Study of SMS Spam Filtering: New Collection and Results
Almeida, Gómez Hidalgo & Yamakami (ACM DOCENG 2011)
How the corpus was collected, and what the authors themselves got out of it.
- A Mathematical Theory of Communication
Claude Shannon, Bell System Technical Journal (1948)
Where the bit comes from, and why uncertainty can be measured at all. Every 'bits removed' figure on this page is his entropy, applied to two classes.
- Rules of Machine Learning: Best Practices for ML Engineering
Martin Zinkevich, Google
A practitioner's account of why the features, not the algorithm, are where the work and most of the mistakes are.