A Flask-based spam detection application that classifies messages as spam or not spam. The model is trained on the Kaggle SMS Spam dataset and provides a simple web interface for predictions.
- Train a machine learning model using Kaggle's spam dataset
- Web interface to enter messages and check if they are spam
- Flask backend for handling predictions
- Preprocessing of text data for better accuracy
- Clone this repository:
git clone https://github.com/Maithilya/Spam-SMS-Detector.git cd Spam-SMS-Detector - Install dependencies:
pip install -r requirements.txt
- Download Dataset :
https://www.kaggle.com/datasets/uciml/sms-spam-collection-dataset
1 Ensure you have Python installed (preferably Python 3.12 or later).
2 Navigate to the project directory:
cd Spam-SMS-Detector3 Run the Flask app:
python Spam-SMS-Detector.py4 Open http://127.0.0.1:5000 in your browser. 5 Enter a message in the provided text box and check for spam classification.
The index.html file is crucial as it serves as the front-end interface for users to enter messages and view classification results. Flask uses Jinja2 templating, which requires index.html to be inside a templates/ directory. If the file is missing or placed incorrectly, the application will throw a TemplateNotFound error.
Fix: Ensure you have an index.html file inside a templates/ folder:
mkdir templatesThen move your index.html file inside the templates/ folder.
Fix: Check if another instance of Flask is already running. Stop it using:
taskkill /F /IM python.exeThen restart the app.
Fix: If Flask keeps restarting or crashing, run it without debug mode:
python spam_detector.py --no-debug(NOTE: everything should be in same folder)
- Deploy on a cloud platform (Heroku, Render, or AWS)
- Improve model accuracy with advanced NLP techniques
- Add user authentication for secured access
Feel free to fork this repo and improve the project! If you face any issues, open an issue on GitHub.
Author: Maithilya Patle 🚀