This project involves building an email classifier using the Multinomial Naive Bayes algorithm to classify emails as spam or non-spam (ham). It fetches the Spambase dataset from the UCI Machine Learning Repository, splits it into training and testing sets, trains a Multinomial Naive Bayes classifier, and evaluates its performance using various metrics.
The email classifier project includes the following steps:
-
Data Fetching: Fetching the Spambase dataset from the UCI Machine Learning Repository using the
fetch_ucirepofunction. -
Data Preprocessing: Splitting the dataset into features (X) and target labels (y), and further dividing them into training and testing sets using the
train_test_splitfunction fromsklearn.model_selection. -
Model Training: Training a Multinomial Naive Bayes classifier using the
MultinomialNBclass fromsklearn.naive_bayes. -
Model Evaluation: Evaluating the performance of the classifier using accuracy scores, confusion matrix, and ROC curve.
To set up the project environment, ensure you have the necessary dependencies installed. You can install them using the following command:
pip install numpy pandas scikit-learn matplotlib ucimlrepo
## Setup
To execute the email classifier code, run the provided Python script (email.py) in your preferred Python environment. Ensure that you have the required datasets accessible.
## Output
Upon execution, the script will output the following:
Train accuracy: The accuracy of the classifier on the training set.
Test accuracy: The accuracy of the classifier on the testing set.
Confusion matrix: A matrix showing the true positives, true negatives, false positives, and false negatives.
ROC curve: A graphical representation of the Receiver Operating Characteristic (ROC) curve.
## License
This project is licensed under the MIT License. See the LICENSE file for details.