The evidence behind
every verdict.
All figures come from 1,026 messages that were set aside before any vocabulary or weights were learned. Spam is the positive class. These are historical evaluation results, kept separate from the live predictions in the studio.
- Smoothing
- α = 0.1
- Mean CV F1
- 92.02%
- Features
- TF-IDF 3,000
Share of all 1,026 test messages labelled correctly.
Of the messages flagged as spam, how many really were?
Of all actual spam, how much did we catch?
Harmonic mean of precision and recall. The selection criterion.
Four outcomes,
two kinds of mistake.
The selected model passed 896 legitimate messages and caught 109 spam. It raised 4 false alerts and let 17 spam through: a spam flag was usually right, but a "ham" verdict is not a guarantee.
Hover or focus a cell. Rows are true labels; columns are predictions. Colour intensity is the share of the row.
Up and to the right is better. Dashed curves join points of equal F1.
Always-ham baseline sits off-chart at 0% recall (precision undefined, reported as 0).
Same data, same features,
different learners.
Naive Bayes achieved 91.21% spam F1 versus 86.81% for Logistic Regression: 7 more spam caught and 3 fewer false alerts. The always-ham baseline is 87.72% accurate yet catches nothing.
- Multinomial NB
- Logistic Regression
- Always ham
Scale: 126 messages = all spam in the test set. Fewer is better for both.
| Model | Accuracy | Precision | Recall | F1 | False alerts | Missed spam |
|---|---|---|---|---|---|---|
| Multinomial Naive BayesSelected | 97.95% | 96.46% | 86.51% | 91.21% | 4 | 17 |
| Logistic Regression | 96.98% | 93.58% | 80.95% | 86.81% | 7 | 24 |
| Always ham | 87.72% | 0.00% | 0.00% | 0.00% | 0 | 126 |
Chosen before the test set was opened.
Three settings per classifier were compared across five stratified folds of the 4,100 training messages. Vectorisation was refitted inside every fold. The family winner with the higher mean spam F1, Naive Bayes with α = 0.1, was selected before final testing.
Solid bars mark the best setting in each family.
What the selected model
got wrong.
A bag-of-words model loses context. “Free” can describe a prize or a friend's afternoon. These examples suggest hypotheses about the errors; they do not establish the cause of every mistake.
Legitimate, flagged as spam
- When you get free, call me
- K k:) sms chat with me.
- If you were/are free i can give. Otherwise nalla adi entey nattil kittum
- Have you laid your airtel line to rest?
Spam, passed as legitimate
- Babe: U want me dont u baby! Im nasty and have a thing 4 filthyguys. Fancy a rude time with a sexy bitch. How about we go slo n hard! Txt XXX SLO(4msgs)
- CALL 09••••••••• & LISTEN TO EXTREME DIRTY LIVE CHAT GOING ON IN THE OFFICE RIGHT NOW TOTAL PRIVACY NO ONE KNOWS YOUR [sic] LISTENING 60P MIN 24/7MP 08•••••••••••+
- RCT' THNQ Adrian for U text. Rgds Vatian
- Hi, the SEXYCHAT girls are waiting for you to text them. Text now for a great night chatting. send STOP to stop this service
- Dear Voucher Holder 2 claim your 1st class airport lounge passes when using Your holiday voucher call 08•••••••••. When booking quote 1st class x 2
- ASKED 3MOBILE IF 0870 CHATLINES INCLU IN FREE MINS. INDIA CUST SERVs SED YES. L8ER GOT MEGA BILL. 3 DONT GIV A SHIT. BAILIFF DUE IN DAYS. I O å£250 3 WANT å£800
Reproducibility note. Figures above are those reported in the project notebook. Retraining locally with scikit-learn 1.8.0 reproduces the selected Naive Bayes model exactly (same confusion matrix). Logistic Regression differs by one message (25 missed spam instead of 24), a small numerical difference between computing environments that does not change the model ranking. Long phone numbers in examples are partially masked.