Skip to content

RezaRHM/spam-classifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Spam Detection using Machine Learning

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

πŸ“Œ Dataset

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: spam and ham
  • Data is automatically downloaded from the source URL during training

🧠 Methodology

  1. Load dataset from URL
  2. Basic data inspection
  3. Train/Test split with stratification
  4. Feature extraction using TF-IDF
  5. Model training:
    • Multinomial Naive Bayes
    • Logistic Regression
  6. Model evaluation:
    • Accuracy
    • Precision
    • Recall
    • F1-score
    • Confusion Matrix
  7. Threshold tuning for spam probability

πŸ“Š Results (Example)

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.


πŸ“ Project Structure:

spam-classifier-ml/ β”œβ”€β”€ notebooks/ β”‚ └── spam_classifier.ipynb β”œβ”€β”€ src/ β”‚ β”œβ”€β”€ train.py β”‚ β”œβ”€β”€ evaluate.py β”‚ └── utils.py β”œβ”€β”€ models/ β”œβ”€β”€ requirements.txt β”œβ”€β”€ README.md └── .gitignore

About

SMS spam detection using TF-IDF + Naive Bayes & Logistic Regression (with threshold tuning)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors