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.txt
uvicorn app:app --reload
Or 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
ham
orspam
-
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.pkl
models/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