SMS Spam Detection Using NLP and Machine Learning โ A Complete Project Overview
With the increasing use of messaging platforms, spam messages have become a daily nuisance for users. From fake lottery wins to phishing links, spam SMS poses both annoyance and threat. To address this, I developed a Spam SMS Detection System using Natural Language Processing (NLP) and Machine Learning, integrated into a user-friendly web interface using Flask.
โ Project Objective
The primary goal of this project is to classify an input SMS message as either "Spam" or "Ham" (not spam). It analyzes the content of the text using machine learning models trained on real-world SMS data.
๐ง Tools & Technologies Used
- Python
- Pandas, NumPy
- Scikit-learn
- NLTK
- Flask
- HTML/CSS
- Pickle
๐ Dataset Used
I used the SMS Spam Collection Dataset, a popular dataset containing over 5,000 labeled messages (ham or spam).
๐ ๏ธ Steps Involved
1. Data Preprocessing
- Lowercased all text
- Removed punctuation and special characters
- Tokenized the text
- Removed stopwords
- Applied stemming using PorterStemmer
2. Feature Extraction
Used TF-IDF Vectorization to convert text into numerical features suitable for ML models.
3. Model Training
- Multinomial Naive Bayes
- Logistic Regression
- Support Vector Machine
Evaluated using accuracy, precision, recall, and F1-score. Multinomial Naive Bayes performed best.
4. Web App with Flask
Built a user interface where users can enter SMS messages. On submission, the message is processed by the model and returns whether it is spam or not.
5. Model Deployment
Used pickle
to save/load the model and deployed the app using Hugging Face Spaces.
๐ User Interface Preview
Clean and responsive. Users input a message and get instant classification feedback.
(You can add a screenshot here)
๐งช Try It Live
Click here to try the Spam Detector App
๐ฆ GitHub Repository
GitHub Repository - SMS Spam Detection
๐ What's Next?
- Improve with deep learning (RNNs)
- Add language detection
- Deploy as mobile PWA
๐ Final Thoughts
This project not only strengthened my understanding of machine learning and NLP, but also gave me hands-on experience with Flask app deployment. I believe such systems can reduce spam and phishing attempts if integrated with real-time platforms.
If you're interested in machine learning, this is a great project to start with!
๐ Connect with Me
๐ www.tauqueeralam.com
๐ฑ LinkedIn | GitHub
You can check out the full project on my GitHub or view a live demo below:
View Demo