This project aims to detect unwanted emails (spam) from a user's inbox. It uses a combination of Natural Language Processing (NLP) techniques and machine learning algorithms to analyze the content, metadata, and patterns of emails, distinguishing between spam and legitimate messages.
The goal is to identify and filter out unsolicited emails (spam) from a user's inbox, ensuring only legitimate and important emails are delivered. This reduces clutter and protects users from phishing attacks, malware, and other malicious activities.
Using a mix of Exploratory Data Analysis (EDA) and NLP, the data is analyzed to identify patterns and correlations. Key steps include:
- Data cleaning
- Text preprocessing through NLP
- Feature engineering and insightful visualizations
Steps involved:
- Stop words removal
- Lemmatization/Stemming (NLP)
- Vectorization using TF-IDF (NLP)
- Tokenization for breaking down email content
- Tokenization: Breaking down email texts into words
- Stemming/Lemmatization: Reducing words to their base form
- TF-IDF: Transforming text into numerical values based on importance
- Bag of Words: Converting text into features for model building
- Logistic Regression
- Random Forest Regressor
- Multinomial Naive Bayes
- numpy: Numerical operations
- pandas: Data manipulation and analysis
- nltk: NLP toolkit for text processing
- seaborn: Statistical visualizations
- matplotlib: Data visualization
- sklearn: Machine learning algorithms
- Logistic Regression: 98% accuracy
- Multinomial Naive Bayes: 97% accuracy
Additional NLP-based features include:
- Word frequency analysis using nltk and collections.Counter
- Character, word, and sentence count analysis
- Heatmap and distribution plots for word frequency and relationships
Through rigorous analysis and the use of advanced NLP techniques, the Multinomial Naive Bayes model yielded the highest predictive accuracy for email spam detection.