classification_model
This project applies machine learning to classify SMS or email messages as spam or ham (not spam) using two algorithms:
- XGBoost Classifier
- Decision Tree Classifier
We compare their performance on the same dataset to evaluate which performs better for spam detection.
The dataset is preprocessed and transformed into numerical features using TF-IDF vectorization.
Both models are trained and evaluated using accuracy, precision, recall, and F1-score.
-
Data Loading & Cleaning
- Lowercased text
- Encoded target labels (ham = 0, spam = 1)
-
Feature Extraction
- Used
TfidfVectorizer(max 3000 features, English stopwords)
- Used
-
Model Training
- Trained both XGBoostClassifier and DecisionTreeClassifier using an 80/20 train-test split
-
Evaluation
- Compared performance with
classification_report,confusion_matrix, and accuracy
- Compared performance with
| Model | Accuracy |
|---|---|
| XGBoost | 0.97 |
| Decision Tree | 0.96 |
XGBoost slightly outperformed Decision Tree.
The notebook includes:
- Confusion matrices for both models
- Accuracy comparison bar chart
Dataset: SMS Spam Collection (Kaggle)