Skip to content
Model performance dashboard · held-out test set

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.

Selected model
Multinomial Naive Bayes
Smoothing
α = 0.1
Mean CV F1
92.02%
Features
TF-IDF 3,000
Accuracy1005 / 1,026

Share of all 1,026 test messages labelled correctly.

Precision109 / 113

Of the messages flagged as spam, how many really were?

Recall109 / 126

Of all actual spam, how much did we catch?

F1-score2PR / (P + R)

Harmonic mean of precision and recall. The selection criterion.

AWhere the errors fall

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.

Confusion matrix · heatmap
n = 1026 test SMS
Predicted hamPredicted spam
Actual ham
Actual spam

Hover or focus a cell. Rows are true labels; columns are predictions. Colour intensity is the share of the row.

Precision vs recall

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).

BModel comparison

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.

Test metrics by model
  • Multinomial NB
  • Logistic Regression
  • Always ham
Mistakes in counts
Multinomial NB4 false alerts · 17 missed
Logistic Regression7 false alerts · 24 missed
Always ham0 false alerts · 126 missed

Scale: 126 messages = all spam in the test set. Fewer is better for both.

Held-out test results for each model
ModelAccuracyPrecisionRecallF1False alertsMissed spam
Multinomial Naive BayesSelected97.95%96.46%86.51%91.21%417
Logistic Regression96.98%93.58%80.95%86.81%724
Always ham87.72%0.00%0.00%0.00%0126
CModel selection

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.

Mean 5-fold CV spam F1NB (α)LR (C)

Solid bars mark the best setting in each family.

DError analysis

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.

All 4 false alertsactual ham

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?
6 of 17 missed spamactual spam

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.