Spam Detection with NLP and Machine LearningSpam Detection with NLP and Machine Learning
The network for creativity
Join 1.25M professional creatives like you
Connect with clients, get discovered, and run your business 100% commission-free
Creatives on Contra have earned over $150M and we are just getting started
Task 4 of my Data Science internship with @Oasis Infobyte: Spam Detection with Machine Learning 📩
I built an NLP classifier that separates spam from legitimate messages using the SMS Spam Collection dataset (5,574 messages).
What I did: • Cleaned the text: lowercasing, punctuation removal, stopword removal and stemming • Converted messages to features with TF-IDF (unigrams + bigrams) • Compared Naive Bayes, Logistic Regression and Linear SVM • Removed 403 duplicate messages before splitting so the test score isn't inflated
Results (best model, Linear SVM): ✅ 98.1% accuracy ✅ 96.6% spam precision, 87.8% spam recall, F1 = 0.92
The main lesson: about 87% of the messages are not spam, so accuracy alone is misleading. A filter that never flags anything would already score ~87%. Precision and recall tell the real story. The misses were mostly very short spam, or spam written like normal chat.
Code, notebook and charts: [GitHub link]
#oasisinfobyte #datascience #nlp #machinelearning #python #spamdetection #internship
Post image
Post image
Post image
Post image
Back to feed
The network for creativity
Join 1.25M professional creatives like you
Connect with clients, get discovered, and run your business 100% commission-free
Creatives on Contra have earned over $150M and we are just getting started