Spam Mail
Classification
An end-to-end Deep Learning project that filters inbox clutter with 98.17% accuracy. From SMOTE balancing to AWS deployment.
The Inbox Clutter
Why do we need a robust classifier?
"I have no cloud computing skills," they say. But insights from the top 1% highlight that ML extends far beyond Jupyter Notebooks. Building the model is just 10% of the journey.
Security Risk
Phishing and scams lurk in seemingly innocent emails.
Productivity
Filtering out noise allows users to focus on what matters.
Deployment
Moving from notebook to a live AWS EC2 instance.
Spam vs. Ham
"Congratulations! You've won a $1,000 gift card. Click here to claim your prize immediately!"
"Hey, just checking in on the project status. Let's sync up tomorrow at 10 AM."
The Experiment
Fighting imbalance with SMOTE and Deep Learning.
"As an aspiring Data Scientist, it’s appalling how much injustice is lurking in this data. Look at how ‘ham’ is dominating ‘spam’! 😱 I put my hands in my pocket and bring out the weapon for justice… SMOTE!!!"
The Neural Network
Accuracy
F1 Score: 0.9840
model = Sequential()
model.add(Dense(64, activation='relu'))
model.add(Dropout(0.7))
model.add(Dense(32, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
model.compile(
optimizer='adam',
loss='binary_crossentropy'
)The Pipeline
From raw CSV to a deployed Streamlit application.
STEP 01
Cleaning
Drop duplicates & Handle Nulls
STEP 02
EDA
Visualize Class Imbalance
STEP 03
SMOTE
Synthetic Minority Over-sampling
STEP 04
Training
Train Neural Network
STEP 05
Saving
Dump Model & Vectorizer
The Launch
Deploying to AWS EC2 with a custom bash script.
AWS EC2 Instance
Launched an Ubuntu instance and configured Security Groups to expose port 8501 for Streamlit.
Automated Script
Wrote `deploy.sh` to handle updates, dependencies, virtual environments, and systemd service creation automatically.
Systemd Service
Ensures the app runs in the background and restarts automatically on failure or reboot.
Description=Streamlit Web Application
[Service]
ExecStart=$(pwd)/venv/bin/streamlit run app.py
Restart=always
Live Demo
Test the deployed model (Simulation).
Live Demo In Progress
We are currently fine-tuning the serving infrastructure on AWS. The live interface will be available soon.