A Flask based webserver which accepts text from user through webservice, and generates prediction whether the text is spam or ham.
The data is a collection of SMS messages tagged as spam or ham that can be found here. First, we will use this dataset to build a prediction model that will accurately classify which texts are spam.
Naive Bayes classifiers are a popular statistical technique of e-mail filtering. They typically use bag of words features to identify spam e-mail. Therefore, We’ll build a simple message classifier using Naive Bayes theorem.
Run the following command on the root dorectory of this project.
Optional commands to create virual environment to install dependency:
Create virtual environment: 'python -m venv spamclassifier'Activate virual environment: 'spamclassifier\Scripts\activate'
Command to start server:
install dependency: 'pip install -r requirements.txt'flask runThis will start flask based spam classifier server in production mode.
To access home page browse to http://localhost:5000
To start python notebook from within python virtual environment follow below commands:
ipython kernel install --user --name=spamclassifierjupyter notebook- open
DataModelling&NaiveBayesModel.ipynbfrom browser.
NOTE: if you are running multiple kernels in jupyter notebook, switch to spamclassifier kernel from kernel->change kernel->spamclassifier from browser.
localhost:5000\trainwill load dataset and create vocabulary, train Naive Bayes model using it.localhost:5000\orlocalhost:5000\indexis the main page of the web app.localhost:5000\predictwill predict the class of text passed. This api will load trained model which were created from 1st url and use it for prediction.