Skip to content

Hamza-Maqsood1/Smart-Email-Agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📧 Smart Email Classification Agent

NLP Model UI Framework

📌 Overview

An NLP-powered email classification system that automatically categorizes incoming emails using classical machine learning. The system preprocesses raw email text, extracts features, and classifies emails in real time through an interactive Chainlit chat interface.


🎯 Problem Statement

  • Manual email sorting is time-consuming and error-prone
  • Goal: Build a lightweight, deployable classifier that categorizes emails accurately without heavy transformer models
  • Emphasis on speed and interpretability over complexity

🔬 Methodology

Pipeline

Raw Email Text → Preprocessing → Feature Extraction → Classification → Chainlit UI

Text Preprocessing (NLTK)

  • Stopword removal
  • Tokenization
  • Stemming

Feature Extraction

  • Bag-of-Words representation from Kaggle email dataset
  • Vocabulary saved as vocab.pkl for inference reuse

Model

  • Multinomial Naive Bayes well-suited for discrete word count features
  • Trained with stratified 80/20 train-test split
  • Model serialized as email_classifier.pkl for deployment

Deployment

  • Chainlit interactive chat UI user pastes email text, gets instant classification

📁 Repository Structure

├── smart_email_agent_train.py  # Training script
├── app.py                      # Chainlit deployment app
├── email_classifier.pkl        # Trained Naive Bayes model
├── vocab.pkl                   # Vocabulary (feature columns)
├── classes.pkl                 # Class labels
└── README.md                   # Documentation

🚀 How to Run

Train the Model

# Install dependencies
pip install scikit-learn nltk pandas chainlit

# Place emails.csv (Kaggle dataset) in project root
# Run training
python smart_email_agent_train.py

Run the Chainlit App

chainlit run app.py

🛠️ Tech Stack

  • Language: Python
  • ML: Scikit-learn (MultinomialNB)
  • NLP: NLTK (tokenization, stopwords, stemming)
  • UI: Chainlit
  • Dataset: Kaggle Email Dataset (Bag-of-Words format)

🔮 Future Work

  • Upgrade to TF-IDF vectorization for better feature representation
  • Add multi-class support (Work, Personal, Spam, Promotions)
  • Replace Naive Bayes with fine-tuned DistilBERT for higher accuracy
  • Deploy as REST API with FastAPI

👤 Author

Hamza Maqsood BS Artificial Intelligence University of Management and Technology, Lahore LinkedIn GitHub

About

NLP-based email classification agent using TF-IDF and Logistic Regression. Interactive UI built with Chainlit.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages