Coder Social home page Coder Social logo

sameer-ahmadd / customer-churn-prediction-mlops3 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from keerthanareddy95/customer-churn-prediction-mlops3

0.0 0.0 0.0 902 KB

This is a comprehensive project focused on understanding and predicting customer churn in the telecommunications industry. Utilizing advanced data analysis and machine learning techniques, this project aims to provide insights into customer behavior and help develop effective strategies for customer retention.

License: MIT License

Python 5.09% Jupyter Notebook 94.91%

customer-churn-prediction-mlops3's Introduction

Customer-churn-prediction-mlops3 ๐Ÿง‘๐Ÿป

This project aims to predict customer churn using machine learning techniques. Customer churn is the phenomenon where customers stop using a company's products or services. By predicting which customers are likely to churn, businesses can take proactive measures to retain them, thereby improving customer retention and profitability.

Project Overview

The objective of this project is to build a machine learning pipeline using ZenML that predicts whether a customer will churn based on various features such as account length, international plan, voice mail plan, call details, and other customer-related metrics. The pipeline includes data ingestion, data cleaning, model training, model evaluation, and deployment. The deployed model can be used to make real-time predictions through a Streamlit web application.

PyPI - Python Version

The purpose of this repository is to demonstrate how ZenML empowers us to build and deploy machine learning pipelines in multiple ways like:

  • By integrating with tools like MLflow for deployment, tracking and more
  • By allowing you to build and deploy your machine learning pipelines easily

๐Ÿ Python Requirements

Let's jump into the Python packages needed. Within the Python environment of your choice, run:

pip install -r requirements.txt

Starting with ZenML 0.20.0, ZenML comes bundled with a React-based dashboard. This dashboard allows us to observe the stacks, stack components and pipeline DAGs in a dashboard interface. To access this, you need to launch the ZenML Server and Dashboard locally, and you must install the optional dependencies for the ZenML server:

pip install "zenml["server"]"
zenml init
zenml up

Installing mlflow integrations using ZenML:

zenml integration install mlflow -y

File Structure:

Screenshot 2024-06-10 084541

Pipeline Development Process ๐Ÿš€:

1. EDA -

output

output1

output2

output3

output4

2. Creation of a Blueprint of the classes -

Steps > ingest_data.py , clean_data.py , model_train.py , evaluation.py

3. Data Cleaning -

data_cleaning.py > -DataPreprocess, -DataDivision

4. Model Development -

Building the model on Train & Test datasets.

5. Defining Evaluation metrics -

src > evaluation.py - defining MSE , RMSE , R2 Score

6. Training pipeline -

  • ingest_data: This step will ingest the data and create a DataFrame.
  • clean_data: This step will clean the data and remove the unwanted columns.
  • train_model: This step will train the model and save the model using MLflow autologging.
  • evaluation: This step will evaluate the model and save the metrics -- using MLflow autologging -- into the artifact store. Screenshot 2024-06-10 080217

The project can only be executed with a ZenML stack that has an MLflow experiment tracker and model deployer as a component. Configuring a new stack with the two components are as follows:

zenml integration install mlflow -y
zenml experiment-tracker register mlflow_tracker --flavor=mlflow
zenml model-deployer register mlflow --flavor=mlflow
zenml stack register mlflow_stack -a default -o default -d mlflow -e mlflow_tracker --set

7. Deployment Pipeline

We have another pipeline, the deployment_pipeline.py, that extends the training pipeline, and implements a continuous deployment workflow. It ingests and processes input data, trains a model and then (re)deploys the prediction server that serves the model if it meets our evaluation criteria. The criteria that we have chosen is a configurable threshold on the MSE of the training. The first four steps of the pipeline are the same as above, but we have added the following additional ones:

  • deployment_trigger: The step checks whether the newly trained model meets the criteria set for deployment.
  • model_deployer: This step deploys the model as a service using MLflow (if deployment criteria is met).

In the deployment pipeline, ZenML's MLflow tracking integration is used for logging the hyperparameter values and the trained model itself and the model evaluation metrics -- as MLflow experiment tracking artifacts -- into the local MLflow backend. This pipeline also launches a local MLflow deployment server to serve the latest MLflow model if its accuracy is above a configured threshold.

The MLflow deployment server runs locally as a daemon process that will continue to run in the background after the example execution is complete. When a new pipeline is run which produces a model that passes the accuracy threshold validation, the pipeline automatically updates the currently running MLflow deployment server to serve the new model instead of the old one. Screenshot 2024-06-10 080257

8. Inference Pipeline

This inference pipeline allows you to use the deployed model to make predictions on new customer data in real-time.

Screenshot 2024-06-10 080237

9. Streamlit Application

Streamlit Application Setup:

  • Create a Streamlit application to serve the model : We design the UI to allow users to input features such as account length, international plan, voice mail plan, call details, and other metrics.

  • Loading the Deployed Model : Use ZenML's prediction service loader to load the deployed model. Integrate the model prediction functionality into the Streamlit app.

  • Making Predictions: The user inputs customer data through the Streamlit UI. The app sends the data to the deployed model, which returns the churn prediction. The prediction is displayed to the user in the app.

Screenshot 2024-06-10 080523

Screenshot 2024-06-10 080014

customer-churn-prediction-mlops3's People

Contributors

keerthanareddy95 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.