Skip to content
Dataset explorer · SMS Spam Collection

5,572 messages.
One in seven is spam.

An existing labelled corpus assembled from several sources, including legitimate messages from the NUS SMS Corpus and spam reported to the UK Grumbletext forum. The raw label is v1 (ham or spam); the text is v2.

Class distribution
5,572raw messages
Ham
4,825
86.59%
Spam
747
13.41%
From raw rows to modelling data
  1. RawRaw CSV rows

    SMS Spam Collection file supplied to the group

  2. CleaningAfter exact duplicates

    403 identical (label, text) copies removed

  3. CleanedUsable, uniquely worded

    43 more removed: empty, conflicting or repeated after normalisation

Training (80%)
3,597 ham · 503 spam
Test (20%)
900 ham · 126 spam

Stratified split, random_state = 42. Zero identical cleaned messages are shared between training and test.

AHam vs spam · message length

Spam talks
for longer.

The median spam SMS is 149 characters, compared with 52 for ham. Length is a useful description, but a long message alone is not evidence of spam, and the models do not use it.

Length distribution (share of each class, raw CSV)HamSpam
Raw statistics
MeasureHamSpam
Messages4,825747
Share86.59%13.41%
Median chars52149
Middle 50%33–92132.5–157
Median words1125
Mean chars71138.9

Exact duplicates in raw CSV: 403.

BInside the vocabulary

Words that tip
the balance.

Terms with the largest gap between the fitted Naive Bayes model's spam and ham likelihoods (log-likelihood ratio). These are associations in this historical corpus; no single word determines a label.

Strongest ham evidence
  • gt-4.82
  • lt-4.81
  • lor-4.65
  • da-4.58
  • later-4.22
  • doing-4.12
  • work-4.05
  • lol-4.05
  • ask-4.01
  • happy-3.96
Strongest spam evidence
  • claim+6.46
  • prize+6.39
  • www+6.20
  • 150p+5.96
  • guaranteed+5.77
  • 18+5.73
  • 16+5.66
  • 1000+5.66
  • ringtone+5.64
  • cs+5.61
Sample messages from the corpus
  • ham

    What r u cooking me for dinner?

  • ham

    So dont use hook up any how

  • ham

    Dont you have message offer

  • ham

    Yesterday its with me only . Now am going home.

  • spam

    Bought one ringtone and now getting texts costing 3 pound offering more tones etc

  • spam

    RGENT! This is the 2nd attempt to contact U!U have WON å£1250 CALL 09••••••••• b4 05•••• T&CsBCM4235WC1N3XX. callcost 150ppm mobilesvary. maxå£7. 50

  • spam

    goldviking (29/M) is inviting you to be his friend. Reply YES-762 or NO-762 See him: www.SMS.ac/u/goldviking STOP? Send STOP FRND to 62•••

  • spam

    Welcome to Select, an O2 service with added benefits. You can now call our specially trained advisors FREE from your mobile by dialling 402.

Shown with their dataset labels. Long numbers are partially masked (••).