An AI-powered email spam detection system built with machine learning and a beautiful modern web interface.
- AI-Powered Detection: Uses TF-IDF vectorization and machine learning to accurately classify spam messages
- Beautiful Modern UI: Stunning gradient design with smooth animations and glassmorphism effects
- Real-time Analysis: Instant spam detection with visual feedback
- Responsive Design: Works seamlessly on desktop, tablet, and mobile devices
- Easy to Use: Simply paste your message and get instant results
Try it out: Email Spam Classifier
- Python 3.x
- Flask - Web framework
- scikit-learn - Machine learning library
- pickle - Model serialization
- HTML5
- CSS3 - Custom styling with gradients and animations
- JavaScript - Interactive functionality
- Font Awesome - Icons
- Google Fonts (Inter) - Typography
- TF-IDF Vectorization - Text feature extraction
- Classification Model - Trained on spam dataset
- Text Preprocessing - Tokenization, stemming, stop word removal
- Python 3.7 or higher
- pip (Python package manager)
-
Clone the repository
git clone https://github.com/pythonicshariful/Email-Spam-Classifier.git cd Email-Spam-Classifier -
Create a virtual environment
python -m venv venv
-
Activate the virtual environment
- Windows:
venv\Scripts\activate
- macOS/Linux:
source venv/bin/activate
- Windows:
-
Install required packages
pip install flask scikit-learn
-
Start the Flask application
python app.py
-
Open your browser Navigate to
http://127.0.0.1:5000 -
Test the classifier
- Paste any email or message into the text area
- Click "Analyze Message"
- Get instant spam detection results!
The machine learning model was trained using the following pipeline:
-
Data Preprocessing
- Convert text to lowercase
- Tokenization
- Remove special characters
- Remove stop words and punctuation
- Apply stemming
-
Feature Extraction
- TF-IDF (Term Frequency-Inverse Document Frequency) vectorization
-
Model Training
- Trained on labeled spam/ham dataset
- Model saved as
model.pkl - Vectorizer saved as
vectorizer.pkl
See main.ipynb for the complete training process.
Email-Spam-Classifier/
├── app.py # Flask application
├── model.pkl # Trained ML model
├── vectorizer.pkl # TF-IDF vectorizer
├── main.ipynb # Model training notebook
├── screenshot.png # UI screenshot
├── templates/
│ └── index.html # Web interface
├── dataset/ # Training data
├── venv/ # Virtual environment
└── README.md # Project documentation
- Gradient Background: Eye-catching purple-violet gradient
- Glassmorphism Card: Modern frosted glass effect
- Animated Particles: Floating background elements
- Smooth Transitions: Micro-animations on all interactions
- Loading States: Visual feedback during analysis
- Color-coded Results:
- 🚨 Red for spam detection
- ✅ Green for safe messages
⚠️ Yellow for warnings- ❌ Red for errors
- User enters a message in the text area
- Frontend sends POST request to
/predictendpoint - Backend preprocesses the text using the trained vectorizer
- ML model predicts if the message is spam or not
- Result is returned as JSON and displayed with beautiful animations
Returns the main web interface
Analyzes a message for spam detection
Request Body:
{
"message": "Your email text here"
}Response:
{
"prediction": "Spam" | "Not Spam",
"message": "Original message"
}Contributions are welcome! Feel free to:
- Report bugs
- Suggest new features
- Submit pull requests
This project is open source and available under the MIT License.
Shariful Islam
- GitHub: @pythonicshariful
- Dataset used for training the spam classifier
- Flask framework for the web application
- scikit-learn for machine learning capabilities
For questions or feedback, please open an issue on GitHub.
Made with ❤️ using Machine Learning
