Obtained from
https://www.kaggle.com/team-ai/spam-text-message-classification
A Jupiter notebook demo with the models bb is available in FastAPISpamDetection_demo.ipynb
The docker file:
- Pulls the FastAPI docker image.
- Copies the app directory to the docker image.
- Set the app directory as the working directory.
- Install requirements listed in requirements.txt
- Train the models
To build the docker image run (this will train the model)
docker build -t spam-detection .
To run the docker image run (this will deploy the API)
docker run -d --name spam-detection -p 80:80 spam-detection
The API documentation is generated automatically by FASTAPI, To access the API documentation go to
Query parameters are part of the URL string and are prefixed by a “?”
For example:
http://localhost/spam_detection_query/?message=WINNER
In Path Variables, the input data is passed to the API as a path in the URL
For example:
http://localhost/spam_detection_path/Hi
The data was preprocessed by
- Removing HTML markup tags
- Removing punctuation marks
- Removing capital letters
The data was randomly separed in using sklearn train_test_split. 80% of the data was used to train 20% of the data was used to test the model and get the accuracy
- MLPClassifier has an accuracy of 98.29%
- KNeighbors has an accuracy of 93.36%
- DecisionTreeClassifier has an accuracy of 95.96%
- RandomForestClassifier has an accuracy of 97.04%