Skip to content

Churn prediction logistic regression model deployment using docker and aws elastic beanstalk

Notifications You must be signed in to change notification settings

rahul-raoniar/chrun-prediction-docker-deployment

Repository files navigation

Churn prediction model deployment

Project aim: Creating a churn prediction model (binary classification) and deploying it using docker container on local Linux Machine and AWS Elastic Beanstalk using awsebcli.

Data Source: https://www.kaggle.com/datasets/blastchar/telco-customer-churn

Project Requirements: python 3.9, pandas, numpy, scikit-learn and docker

Operating System: Linux

Tools: Visual Studio Code and Linux command line

The project involved the following steps:

Loading dataset & EDA:

  • Downloading, loading, cleaning and preparing data for analysis
  • Performing exploratory data analysis
  • Performing a feature importance analysis using the concept of Risk Ratio
  • Performing correlation analysis for feature selection

Feature engineering:

  • Performing feature engineering which involves One-Hot Encoding for categorical variables

Model training:

  • Fitting and training a logistic regession binary classification model using scikit-learn's LogisticRegression class

Model Evaluation:

  • Model evaluation using basic evaluation matric such as accuracy
  • Identifying cut-off for achieving maximum accuracy
  • Computing auc-roc (due to target class imbalance)
  • Used pickle library to save and load the model

Creating a flask-based web application:

  • Created a basic flask app churn-serving.py for predicting churn based on single observation input
  • Tested flask app's prediction using request python library
  • Used pipenv to manage project dependencies. This will create Pipenv and Pipenv.lock files. It manages exact depndencies that we need to run the application.
  • Installed gunicorn using pipenv which is a production ready WSGI server tool. It can handle http request without any issues.

Dockerizing the application:

  • Installed docker for creating and running a docker container
  • Created a Dockerfile and added instructions
  • Built the churn-prediction docker container

Making predictions on local Linux machine using request library

  • Run the docker container and tests to check for model prediction

Deploying model using AWS Elastic Beanstalk

  • Locally tested and deployed on AWS using Elastic Beanstalk CLI (awsebcli)
  • Tested the prediction using the AWS Application host's IP address

Releases

No releases published

Packages

No packages published

Languages