Skip to content
VD
All projects

AI & NLP, 2025

Email & SMS Spam Classifier

A text classifier that labels messages as spam or not spam, with a Streamlit interface for live predictions.

Multinomial Naive Bayes + TF-IDF1,034 test messagesPredictedHamSpamActualHamSpam896030108Dataset balanceHam 87.4%Spam 12.6%1.00precision: no real message flagged97.1%accuracy
Accuracy (MultinomialNB)
97.1%
Precision
1.00
Test messages
1,034

The problem

Spam filters must avoid false positives — flagging a real message as spam is worse than letting one spam through. With an imbalanced dataset, precision matters more than raw accuracy.

What it does

  • Preprocessing with tokenisation, stop-word removal and Porter stemming.
  • Compared Count and TF-IDF vectorisation and several Naive Bayes variants.
  • Selected Multinomial Naive Bayes for zero false positives on the test set.
  • Vectoriser and model pickled and loaded by the Streamlit app.

Built with

  • Python
  • scikit-learn
  • NLTK
  • TF-IDF
  • Pandas
  • Streamlit

From the repository

Screenshots and charts as they appear in the project's code and notebooks.

Ham vs spam share in the dataset
Ham vs spam share in the dataset
Most frequent words in ham and spam messages
Most frequent words in ham and spam messages