Skip to content

Latest commit

 

History

History
 
 

chapter-05-deployment

Chapter 5. Deployment

Preparation

If you don't have the model from the previous chapter, run 05-deploy.ipynb to generate the pickle file.

Running without Docker

First, install flask:

pip install flask

Run the service:

python churn_serving.py

Test it from python:

import requests
url = 'http://localhost:9696/predict'
response = requests.post(url, json=customer)
result = response.json()

Managing dependencies with Pipenv

Install pipenv:

pip install pipenv

Install the depencencies from the Pipfile:

pipenv install

Enter the pipenv virtual environment:

pipenv shell

And run the code:

python churn_serving.py

Alternatively, you can do both steps with one command:

pipenv run python churn_serving.py

Now you can use the same code for testing the model locally.

Running with Docker

Build the image (defined in Dockerfile)

docker build -t churn-prediction .

Run it:

docker run -it -p 9696:9696 churn-prediction:latest