1.
Aim
The aim of this experiment is to classify email messages as Spam or Not Spam (Ham) using the
Naive Bayes classification algorithm with machine learning techniques.
2. Objective
To load and preprocess an email spam dataset.
To convert text messages into numerical features using Count Vectorizer.
To train a Multinomial Naive Bayes classifier for spam detection.
To evaluate the model performance using accuracy and classification report.
To develop a function that can classify any user-entered message as Spam or Ham.
3. Abstract Description
This project implements a Spam Email Classification System using supervised machine learning.
The model is trained on the Spam SMS dataset to automatically detect whether a given message
is spam or not.
Dataset Details:
Dataset Name: Spam SMS Dataset
Source: Kaggle
File Used: [Link]
Encoding: latin-1
Total Records: 5,572 messages
Attributes Used:
v1 Label (spam / ham)
v2 Message text
The labels are converted into numeric form where spam = 1 and ham = 0.
4. Tools & Technologies
Programming Language
Python
Libraries Used
Pandas – Data loading and manipulation
NumPy – Numerical operations
Scikit-learn –
train_test_split for data splitting
CountVectorizer for feature extraction
MultinomialNB for classification
accuracy_score and classification_report for evaluation
Methodology
Load dataset and clean required columns
Encode labels (spam/ham 1/0)
Split data into training and testing sets
Convert text into word frequency vectors
Train Naive Bayes classifier
Evaluate model performance
Predict spam or ham for new user input
5. Optimization
Stop-word removal is applied using CountVectorizer(stop_words='english') to reduce noise.
Multinomial Naive Bayes is chosen because it is efficient for text classification problems.
The dataset is split using an 80–20 train-test ratio for better generalization.
Feature extraction using word frequency improves classification accuracy.
The model achieves high accuracy (~98.5%), indicating good optimization.
6. Conclusion
The Spam Email Classification system successfully identifies spam and non-spam messages
with high accuracy and efficiency.
Using Naive Bayes and word frequency features, the model performs well on real-world email
messages.
The implemented function allows users to input any message and instantly receive a prediction.
This approach proves that machine learning techniques are effective for automated spam
detection systems.