This code runs a small flask based webserver which can make predictions on the given coffee samples total cupping score provided the following attributes are passed as a JSON.
The script train.py can be used to train a model with the final model and parameters. After running it will print the current model and parameters as well as the auc and rsme scores for the model. A model.bin
artifact will be saved in the ./models
directory. Note that these are ignored by git and therefore not saved to github. You need to run this before you can run the application.
First set up the virtual environment as documented in the root README. Then run:
pipenv install
The below command will run the application locally within the virtual environment.
make dev
The below command will both build the Docker image and run it.
make run-with-docker
curl --header "Content-Type: application/json" \
--request POST \
http://localhost:8000/predict \
-d @test_data/coffee_sample.json
import requests
coffee_sample = {
"moisture": "0.12",
...
}
url = "http://localhost:8000/predict"
requests.post(url, json=coffee_sample).json()
# returns python dictionary of response
There is a sample code for this here which you can run with pipenv run python request.py
.
Run the following commands to deploy this project to Heroku.
# login into Heroku
heroku login
heroku container:login
# only need to run this the first time to create the app
make create-app
make push-app
make release-app
``