Machine Learning · Guided project
SMS Spam Classifier with Precision and Recall — Guided Project
Build a classifier that flags spam messages, choose the right metric and threshold, and save the pipeline so it can classify new messages.
- Intermediate
- ~5 hours
- 5 steps
The brief
Use a public SMS spam dataset. Turn text into features with TF-IDF, train logistic regression and a tree-based model, and evaluate with a confusion matrix, precision and recall. Decide a threshold based on the cost of hiding a real message vs letting spam through, and save the final pipeline with joblib.
Skills you will use: Text features (TF-IDF) · Classification · Confusion matrix · Threshold tuning · joblib
Build it
Step by step
Tick each step as you finish it. 0 of 5 done.
-
Step 1Explore
Check class balance and read 20 examples of each class.
-
Step 2Pipeline
TfidfVectorizer + LogisticRegression in one Pipeline; stratified train/test split.
-
Step 3Evaluate
Confusion matrix, precision, recall, F1 and PR-AUC with cross-validation.
-
Step 4Choose a threshold
Compare thresholds 0.3, 0.5 and 0.7 and justify your choice for an SMS app.
-
Step 5Save and demo
Save the pipeline, write predict(message) and test it on 10 new messages you write yourself.
Self-review before you call it done
Tick each point once your project really meets it. These are the things an interviewer will look for.
Check all 4 points, then mark the project as finished.
Next