Skip to content

Live customer churn prediction based on Telco Dataset using Sklearn, Flask API, Docker, and Heroic for deployment

Notifications You must be signed in to change notification settings

SabeehHassany/Churn-Prediction

Repository files navigation

Churn Prediction Flask App

A Flask application that predicts customer churn based on user input. The application is built using Python and machine learning models to make predictions about customer churn probability. The app accepts customer details via a web form and returns a prediction along with the probability of churn.

Watch the video demo

Table of Contents

Project Overview

This project uses a machine learning model to predict whether a customer is likely to churn based on several customer features such as tenure, monthly charges, phone service, etc. The model is integrated with a Flask web application to provide an interactive interface where users can input customer information and receive a churn prediction.

Languages and Frameworks

  • Programming Language: Python
  • Framework: Flask (Backend)
  • Machine Learning: Scikit-learn
  • Containerization: Docker
  • Libraries:
    • Pandas
    • NumPy
    • Joblib (for model persistence)
    • Scikit-learn (for the machine learning model)

Features

  • Web-based interface to enter customer details.
  • Predict customer churn using a pre-trained machine learning model.
  • Display prediction result with probability.
  • Containerized using Docker for easy deployment.

Requirements

Make sure you have the following installed:

  • Python 3.9 or later
  • Flask
  • Docker (if you plan to run the app inside a container)

Setup and Installation

1. Clone the Repository

git clone https://github.com/your-username/churn-prediction-app.git
cd churn-prediction-app

2. Create a Virtual Environment

To avoid dependency conflicts, it's recommended to use a virtual environment.

python3 -m venv venv
source venv/bin/activate   # On Windows, use `venv\Scripts\activate`

3. Install Required Packages

Install the necessary Python packages listed in requirements.txt:

pip install -r requirements.txt

Run the Application

After setting up the environment and installing dependencies, you can run the Flask app:

export FLASK_APP=app.py
export FLASK_ENV=development
flask run

Build the Docker Image

To build the Docker image for the Flask app, run:

docker build -t churn-prediction-app .

Run with Docker

Run the container mapping the local machine’s port 5000 to the container’s port 5000:

docker run -p 5000:5000 churn-prediction-app

Future Directions

  • Enhance the UI/UX to make it more visually appealing and intuitive.
  • Add the ability to retrain the model with updated data directly through the web interface.
  • Provide users with an option to upload bulk customer data for batch churn predictions.
  • Allow users to export prediction results in formats like CSV or JSON.
  • Add authentication and user management for enhanced security.

About

Live customer churn prediction based on Telco Dataset using Sklearn, Flask API, Docker, and Heroic for deployment

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published