This project implements a spam detection system using classical Machine Learning techniques.
The goal is to classify SMS messages as spam or ham (not spam).
The project compares two baseline models:
- Multinomial Naive Bayes
- Logistic Regression
The dataset used in this project is the SMS Spam Collection Dataset from UCI:
https://archive.ics.uci.edu/ml/datasets/SMS+Spam+Collection
- ~5,500 labeled SMS messages
- Labels:
spamandham - Data is automatically downloaded from the source URL during training
- Load dataset from URL
- Basic data inspection
- Train/Test split with stratification
- Feature extraction using TF-IDF
- Model training:
- Multinomial Naive Bayes
- Logistic Regression
- Model evaluation:
- Accuracy
- Precision
- Recall
- F1-score
- Confusion Matrix
- Threshold tuning for spam probability
| Model | Accuracy | Spam Recall |
|---|---|---|
| Naive Bayes | ~0.98 | ~0.85 |
| Logistic Regression | ~0.98 | Higher / Tunable |
Logistic Regression provides better flexibility through threshold adjustment, allowing control over precision vs recall trade-off.
spam-classifier-ml/ βββ notebooks/ β βββ spam_classifier.ipynb βββ src/ β βββ train.py β βββ evaluate.py β βββ utils.py βββ models/ βββ requirements.txt βββ README.md βββ .gitignore