Skip to content

codedbyasim/Email-Spam-Detection-system

Repository files navigation

📧 Email Spam Detection System using Naive Bayes

This project is a simple yet effective spam detection system that utilises the naive Bayes classifier to classify emails as either spam or not spam. It utilizes text preprocessing techniques, TF-IDF vectorization, and machine learning to build a spam filter based on the popular spam.csv dataset.


🧠 Machine Learning Algorithm

  • Multinomial Naive Bayes is used for classification because it performs well with text data and discrete features (like word counts or frequencies).

📂 Dataset

  • Dataset: spam.csv

  • Columns:

    • v1: Label (spam/ham)
    • v2: Text message

🛠️ Features

  • Text cleaning (punctuation removal, stopwords removal)

  • Text stemming using PorterStemmer

  • TF-IDF Vectorisation

  • Train-Test Split

  • Model Training & Evaluation

  • Performance metrics:

    • Accuracy
    • Confusion Matrix
    • Classification Report

🧪 Libraries Used

pandas
numpy
string
nltk
sklearn

📊 Model Evaluation

The model is evaluated using:

  • Accuracy Score
  • Confusion Matrix
  • Classification Report

📝 How to Run

  1. Clone the repository:

    git clone https://github.com/yourusername/Email-Spam-Detection.git
    cd Email-Spam-Detection
  2. Install required libraries:

    pip install -r requirements.txt
  3. Run the Jupyter Notebook:

    jupyter notebook Email_Spam_Detection_system_using_Naive_Bayes.ipynb

📌 Project Structure

📁 Email-Spam-Detection/
│
├── Email_Spam_Detection_system_using_Naive_Bayes.ipynb
├── spam.csv
├── README.md
└── requirements.txt

🤖 Sample Result

Metric Value
Accuracy 97%+
Precision High
Recall High

✅ Future Improvements

  • Add GUI or Web Interface (using Streamlit/Flask)
  • Deploy the model using FastAPI or Flask
  • Add more datasets and deep learning models

👨‍💻 Author

Asim Hanif GitHub | LinkedIn Software Engineering Student & ML Enthusiast

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published