This project is a Machine Learning + Flask + MySQL pipeline that classifies SMS and Email messages as Spam 🚨 or Not Spam ✅.
It demonstrates end‑to‑end skills: data preprocessing, model training, web app development, database integration, and deployment readiness.
📁 Project Structure
ML_Projects/
├── app.py # Flask main app
├── spam.csv # Dataset
├── trained_model.pkl # Saved ML model
├── vectorizer.pkl # TF-IDF vectorizer
├── requirements.txt # Dependencies
├── README.md # Project documentation
├── templates/ # HTML templates
│ ├── home.html
│ ├── sms.html
│ ├── email.html
│ └── history.html
└── DB/ # Database scripts
├── schema.sql # Table creation
└── seed.sql # Sample data insert
During development, multiple Naive Bayes variants were evaluated. Multinomial Naive Bayes (MNB) was selected as the final production model due to its flawless precision, ensuring critical user messages are never misclassified as spam.
| Model Variant | Accuracy | Precision | Why it matters |
|---|---|---|---|
| Multinomial NB | 97.1% | 100% | Selected: Zero false positives. Safe for user inboxing. |
| Bernoulli NB | 98.4% | 99.2% | High accuracy, but allowed some false positives. |
| Gaussian NB | 86.9% | 50.7% | High error rate; underperformed on text data. |
- Algorithms: Multinomial, Bernoulli, and Gaussian Naive Bayes
- NLP Techniques: TF-IDF Vectorization, Text Tokenization, Stop-word handling
- Deployment Pipeline: Flask Web Framework, MySQL Database backend