This project is a flask based web app that detects spam messages using Naive Bayes classifier algorithm of machine learning. The application is built with Python 3 and Flask. It uses CountVectorizer
with MultinomialNB
from naive_bayes
to achieve the best performance. The vectorizer and model are serialized using pickle
for easy access in the Flask web app.
The Spam Detector classifies messages as spam or not spam using a machine learning model. The model is trained with the MultinomialNB
algorithm and CountVectorizer
to convert text data into numerical format. The Flask web application serves as an interface for users to input messages and get predictions.
Follow these steps to set up and run the project:
-
Create a virtual environment:
python -m venv myenv
-
Activate the virtual environment:
.\myenv\Scripts\activate
source myenv/bin/activate
After activation, your terminal prompt will change to indicate that you are now working inside the virtual environment.
-
Install the required packages:
pip install -r Requirements.txt
-
Run the Flask application:
flask run
- Open your web browser and go to
http://127.0.0.1:5000
- You will see an input field where you can enter a message.
- Submit the message to get the prediction of whether it is spam or not spam.
Here is a brief example of how the application works:
- Enter a message such as
Congratulations! You've won a $1000 gift card. Click here to claim your prize here in this below link https://bitelottery4567.com/3frfty-ofgdf.
- Click the "Predict" button.
- The application will process the message and display the result, indicating whether the message is spam.
- Ensure that the CountVectorizer and MultinomialNB model are properly serialized and available for the Flask app to load.
- The project structure should include the necessary files such as app.py, the serialized model file, and Requirements.txt.