An advanced AI-powered email protection system that accurately classifies spam messages with 98%+ accuracy using machine learning and natural language processing.
- Real-time spam detection with probability scoring
- Interactive analytics dashboard with performance metrics
- Word cloud visualizations of key spam/ham indicators
- Model export functionality for integration
- Responsive dark-mode UI with modern design
- Python 3.8+
- pip package manager
git clone https://github.com/codewithshami/HamOrSpam-Classifier.git
cd HamOrSpam-Classifier
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirement.txtstreamlit run app.py- Input your message in the text area
- Click Analyze Message button
- View spam/ham classification with confidence score
- Explore keyword analysis and probability distribution
graph TD
A[Raw Email Text] --> B[TF-IDF Vectorization]
B --> C[SMOTE Balancing]
C --> D[Logistic Regression]
D --> E[Spam/Ham Prediction]
- Source: Enron Spam Dataset
- Samples: 5,000+ labeled emails
- Class Balance: 70% Ham / 30% Spam
| Metric | Score |
|---|---|
| Accuracy | 98.2% |
| Precision | 97.8% |
| Recall | 98.5% |
| F1 Score | 98.1% |
@app.post("/predict")
def predict(message: str):
"""
Returns spam classification results
Parameters:
message: Email content to analyze
Returns:
{
"prediction": "spam/ham",
"confidence": 0.95,
"spam_probability": 0.92,
"ham_probability": 0.08
}
"""Create .env file:
DEBUG_MODE=False
THRESHOLD=0.85
MAX_FEATURES=3000- Backend: Python, Streamlit
- ML Libraries: scikit-learn, pandas, numpy
- Visualization: matplotlib, seaborn, wordcloud
- Deployment: Streamlit Cloud
You can deploy the app with:
pip install streamlit
pip install -r requirement.txt
streamlit run app.py- Fork the repository
- Create your feature branch (
git checkout -b feature/NewFeature) - Commit changes (
git commit -m 'Add NewFeature') - Push to branch (
git push origin feature/NewFeature) - Open Pull Request
MIT License - See LICENSE for details
Mohd Shami 📧 shamimohd367@gmail.com 💼 LinkedIn 🔗 Project Repository
Built with ❤️ and Python
```










