A machine learning project that classifies emails as spam or not spam using Logistic Regression, with a deployable Flask API for real-time classification.
This project involves building a machine learning model to classify emails as spam or not spam. The model is trained using a dataset from Kaggle and is implemented in a Jupyter Notebook using Logistic Regression. Additionally, a Flask API is provided for interfacing with the trained model to classify emails. The API can be accessed locally by running the Flask server or through the hosted version here.
You can explore the frontend application and test its functionality by visiting the hosted site here. The source code for the frontend is available in a separate repository, which can be found here.
The dataset used for training the model is sourced from Kaggle and can be found in datasets/emails.csv
. The model, trained on this dataset, achieves an accuracy of 98.34% on the test data.
EmailSpamClassifier.ipynb
: Jupyter Notebook containing the implementation of the spam classifier model.models/
: Directory where the trained model and feature extractor are saved.datasets/
: Directory where the datasets are stored.app.py
: Flask API for interfacing with the trained model.requirements.txt
: Python package dependencies.{
"message": "Your email content here."
}
{
"message": "Your email content here.",
"prediction": "spam or not spam"
}
{
"message": "click here to win free prize"
}
{
"message": "click here to win free prize",
"prediction": "spam"
}
git clone https://github.com/BilalM04/email-spam-classifier.git
cd email-spam-classifier
pip install -r requirements.txt
jupyter notebook
EmailSpamClassifier.ipynb
in the Jupyter Notebook server.input_mail
to test your own input.
input_mail = [""]
python app.py
http://127.0.0.1:####/
, where ####
is the port number.The frontend for this project is a web application built using React.js and styled with CSS. It allows users to input email messages and receive a classification of whether the email is spam or not. The frontend communicates with this backend API to utilize the machine learning model for classification. You can explore the frontend application and test its functionality by visiting the hosted site here. The source code for the frontend is available in a separate repository, which can be found here.