https://github.com/rickydoan/ml-email-spam_classification
https://github.com/rickydoan/ml-email-spam_classification
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/rickydoan/ml-email-spam_classification
- Owner: RickyDoan
- Created: 2024-12-22T13:29:50.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-23T10:28:43.000Z (over 1 year ago)
- Last Synced: 2024-12-27T02:18:19.523Z (over 1 year ago)
- Language: Jupyter Notebook
- Size: 943 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Email Spam Classification with Machine Learning
* Play with app : https://ricky-email-spam-classification.streamlit.app/
* This project demonstrates how to build a machine learning model for classifying emails as spam or not spam. The model is trained using natural language processing (NLP) techniques and machine learning algorithms to identify spam emails accurately.
### 1/ Libraries Used
* Stopwords: For removing common words that don't add much meaning to the text (e.g., "and", "the").
* Tokenize: To split the text into individual words (tokens).
* String: For removing punctuation and unnecessary characters.
* CountVectorizer: Converts text data into a matrix of token counts.
* TfidfVectorizer: Converts text data into a matrix of Term Frequency-Inverse Document Frequency (TF-IDF) values.
* Scikit-learn: Used for building and evaluating machine learning models.
### 2/ Project Steps
#### Data Preprocessing:
* Cleaned and preprocessed email text data by removing stop words, punctuation, and tokenizing the text.
Vectorization:
* Used CountVectorizer and TfidfVectorizer to convert text into numerical features.
Model Training:
* Trained a classification model such as : MultinomialNB, GaussianNB, Xgboost, RandomizeSearchCV, Optuna to predict whether an email is spam or not.
* Focused on optimizing the Recall metric to reduce false negatives (missed spam emails).
### 3/ Evaluation:
* Evaluated the model's performance using precision, recall, and accuracy metrics:
* The accuracy is 96% with 100% recall for kaggle datasets.
* According to real world spam, the accuracy is around 70% because the data was trained from my datasets has still not updated, so that some new kind of spam email was not detected.
* Datasets from kaggle : https://www.kaggle.com/datasets/uciml/sms-spam-collection-dataset
### 4/ Results
The model can effectively classify emails as spam or not, with a focus on minimizing false negatives.
The use of CountVectorizer and TfidfVectorizer significantly improved the model's performance.