Skip to content

codexshami/HamOrSpam-Classifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🛡️ HamOrSpam - AI Email Classifier

App Screenshot

Python Version Streamlit License: MIT Accuracy

An advanced AI-powered email protection system that accurately classifies spam messages with 98%+ accuracy using machine learning and natural language processing.


✨ Key Features

  • 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

🚀 Quick Start

Prerequisites

  • Python 3.8+
  • pip package manager

Installation

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.txt

Running the App

streamlit run app.py

🖥️ User Interface

App Screenshot

App Screenshot App Screenshot

Prediction Interface

  1. Input your message in the text area
  2. Click Analyze Message button
  3. View spam/ham classification with confidence score
  4. Explore keyword analysis and probability distribution

Demo Screen

Demo Screen

Analytics Dashboard

Analytics Screen Analytics Screen

Data Statistics

App Screenshot

Word Frequency

App Screenshot


🧠 Technical Details

Model Architecture

graph TD
    A[Raw Email Text] --> B[TF-IDF Vectorization]
    B --> C[SMOTE Balancing]
    C --> D[Logistic Regression]
    D --> E[Spam/Ham Prediction]
Loading

Dataset

  • Source: Enron Spam Dataset
  • Samples: 5,000+ labeled emails
  • Class Balance: 70% Ham / 30% Spam

Performance Metrics

Metric Score
Accuracy 98.2%
Precision 97.8%
Recall 98.5%
F1 Score 98.1%

Accuracy

App Screenshot


📚 Documentation

API Endpoints

@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
        }
    """

Configuration

Create .env file:

DEBUG_MODE=False
THRESHOLD=0.85
MAX_FEATURES=3000

💻 Tech Stack

  • Backend: Python, Streamlit
  • ML Libraries: scikit-learn, pandas, numpy
  • Visualization: matplotlib, seaborn, wordcloud
  • Deployment: Streamlit Cloud

🌐 Deployment

You can deploy the app with:

pip install streamlit
pip install -r requirement.txt
streamlit run app.py


🤝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/NewFeature)
  3. Commit changes (git commit -m 'Add NewFeature')
  4. Push to branch (git push origin feature/NewFeature)
  5. Open Pull Request

📜 License

MIT License - See LICENSE for details


📬 Contact

Mohd Shami 📧 shamimohd367@gmail.com 💼 LinkedIn 🔗 Project Repository


Built with ❤️ and Python
```

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors