If you don't have the model from the previous chapter, run 05-deploy.ipynb to generate the pickle file.
First, install flask:
pip install flaskRun the service:
python churn_serving.pyTest it from python:
import requests
url = 'http://localhost:9696/predict'
response = requests.post(url, json=customer)
result = response.json()Install pipenv:
pip install pipenvInstall the depencencies from the Pipfile:
pipenv installEnter the pipenv virtual environment:
pipenv shellAnd run the code:
python churn_serving.pyAlternatively, you can do both steps with one command:
pipenv run python churn_serving.pyNow you can use the same code for testing the model locally.
Build the image (defined in Dockerfile)
docker build -t churn-prediction .Run it:
docker run -it -p 9696:9696 churn-prediction:latest