An advanced NLP-based Spam Detection System built using Python, Machine Learning, TF-IDF, Threshold Tuning, and Flask with a modern futuristic UI inspired by AI applications.
SpamShield AI classifies email/messages into:
- ✅ Ham (Safe Message)
- 🚨 Spam (Suspicious/Fraudulent Message)
This project focuses not only on prediction accuracy but also on:
- Precision & Recall optimization
- Threshold tuning
- False positive reduction
- Real-world spam detection behavior
- Professional AI-style UI
- Used Spam/Ham dataset from Kaggle
- Performed analysis on real-world SMS/email messages
Performed complete NLP preprocessing pipeline:
- Lowercasing
- Contractions handling
- Tokenization
- Stopword removal
- Lemmatization
- Punctuation removal
Libraries used:
nltk
contractions
stringUsed:
TF-IDF Vectorizationto convert text into numerical features.
Multiple Machine Learning models were trained and compared.
Examples:
- Logistic Regression
- Naive Bayes
- Random Forest
- SVM
- KNN
Compared models using:
- Accuracy
- Precision
- Recall
- F1-Score
- Confusion Matrix
- Precision-Recall Curve
Main focus was reducing false positives.
Performed tuning to improve model performance.
Optimized:
- Threshold values
- Precision/Recall balance
- Spam sensitivity
Instead of using default threshold:
0.6 - 0.7custom threshold tuning was applied after analyzing:
- Precision Recall Curve
- Confusion Matrix
- Prediction probabilities
Final threshold improved real-world spam classification.
After comparing all models:
✅ Best performing model was selected
✅ Exported as:
best_model.pklUsed later in Flask application.
The trained model was integrated with Flask.
Features:
- AI-style futuristic UI
- Dark/Light mode
- Real-time message analysis
- Spam/Ham result card
- Reset button
- Responsive design
The UI was inspired by modern AI interfaces and customized further for this project.
Main improvements done:
- Futuristic glassmorphism effect
- AI-themed dark mode
- Clean result animations
- Professional user experience
Spam_Ham_NLP_Project/
│
├── static/
│ ├── style.css
│ └── script.js
│
├── templates/
│ └── index.html
│
├── app.py
├── best_model.pkl
├── requirements.txt
├── Spam_ham_2.ipynb
└── README.md- Python
- Flask
- Scikit-learn
- TF-IDF
- NLP
- HTML
- CSS
- JavaScript
- NLTK
- contractions
- Modern AI Dashboard
- Spam/Ham analysis card
- Professional UI
- Clean minimal design
- Responsive layout
- Fraud/spam email classified successfully
- Safe message classified correctly
git clone pip install -r requirements.txtpython app.py- Email phishing detection
- Deep Learning models
- BERT/Transformers integration
- User authentication
- API deployment
- Live email scanning
Passionate about:
- Data Science
- Machine Learning
- NLP
- AI-based applications
✅ End-to-End NLP Project
✅ Real-world Spam Detection
✅ Threshold Tuning
✅ Precision/Recall Optimization
✅ Flask Deployment
✅ Professional AI UI
✅ Complete ML Workflow Included
This project was built not just for accuracy, but to understand:
- how NLP pipelines work,
- how models behave in real-world scenarios,
- and how threshold tuning can improve practical spam detection systems. =======



