A FastAPI-based project to detect spam emails using machine learning. This repository includes everything from training to deploying a REST API powered by a trained model.
- Python 3.8+ | dev --version: Python 3.13
- pip
pip install -r requirements.txtuvicorn app:app --reloadOr using the Procfile (e.g., for Heroku):
web: uvicorn app:app --host=0.0.0.0 --port=${PORT:-8000}-
Dataset file:
email.csv -
Contains real-world email examples labeled as
hamorspam -
Mapping used in preprocessing:
df["Category"] = df["Category"].map({"ham": 0, "spam": 1})
-
Total records: [ADD_TOTAL_RECORDS]
- 🟢 Ham: [ADD_HAM_COUNT]
- 🔴 Spam: [ADD_SPAM_COUNT]
Replace this image path with your actual chart at
docs/spam_pie_chart.png
-
Training notebook:
Spam Email Detection Machine Learning Train Script.ipynb -
Saved models:
models/spam_model.pklmodels/tfidf_vectorizer.pkl
{
"text": "Congratulations! You've won a free iPhone. Click here to claim."
}
{
"prediction": "spam"
}notebooks/Api Example.ipynb: Example API interactionsnotebooks/Spam Email Detection Machine Learning Train Script.ipynb: Model training and evaluation
.
├── app.py
├── requirements.txt
├── requirements.lock.txt
├── Dockerfile
├── docker-compose.yml
├── AUTHOR
├── data/
│ └── email.csv
├── models/
│ ├── spam_model.pkl
│ └── tfidf_vectorizer.pkl
├── notebooks/
│ ├── Api Example.ipynb
│ └── Spam Email Detection Machine Learning Train Script.ipynb
└── docs/
└── spam_pie_chart.png
└── avatar.png
GNU Affero General Public License v3.0
