Overview
In this chapter, we will delve into the deployment process of our machine learning model. We’ll start by taking the Jupyter notebook where our model resides and save it to a file, which we’ll call ‘model.bin.’ The next step is to load this model from a different process, a web service aptly named the ‘churn service,’ which houses this model.
The primary purpose of this service is to identify churning customers. To put it into context, imagine we also have another service called the ‘marketing service,’ which holds comprehensive customer information. For a specific customer, we want to determine their churning probability. The marketing service sends a request to the churn service, providing the necessary customer information. The churn service processes this request and returns the prediction. Subsequently, based on this prediction, the marketing service can decide whether to send a promotional email with a discount offer.
To transform the model into a web service, we will leverage Flask, a powerful framework for creating web services. Moreover, we aim to isolate the dependencies for this service to prevent interference with other services on our machine. To achieve this isolation, we will create a dedicated environment for Python dependencies using pipenv. Following that, we’ll add another layer, which will comprise system dependencies, and for this purpose, we’ll employ Docker.
Once the local setup is complete, the final step is deploying our service to the cloud. We will containerize the application and deploy it to AWS Elastic Beanstalk, taking advantage of the cloud’s scalability and reliability.