Skip to content

deepakjha018/Customer-Churn-Prediction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

10 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“Š Customer Churn Prediction Dashboard

๐Ÿš€ Live Demo

๐Ÿ”— Try the application here:

https://customer-churn-predictor-vk18.streamlit.app/

Machine Learning Python Scikit-Learn Streamlit License


๐Ÿ“Œ Project Overview

Customer churn is one of the biggest challenges faced by subscription-based businesses.
This project predicts whether a telecom customer is likely to leave the service using Machine Learning.

The system analyzes customer demographics, account information, subscribed services, and billing details to estimate churn probability and provide actionable business recommendations.

This project follows a complete Data Science workflow:

Data Collection
        โ†“
Exploratory Data Analysis
        โ†“
Data Preprocessing
        โ†“
Feature Engineering
        โ†“
Handling Class Imbalance
        โ†“
Model Training
        โ†“
Model Evaluation
        โ†“
Interactive Dashboard Deployment

๐ŸŽฏ Problem Statement

Telecom companies lose revenue when customers discontinue services. Identifying customers who are likely to churn allows companies to take preventive actions.

The objective is to build a machine learning solution that:

  • Predicts customer churn probability
  • Identifies important churn factors
  • Provides retention recommendations
  • Helps businesses reduce customer loss

๐Ÿ“‚ Dataset Information

Dataset Used:

IBM Telco Customer Churn Dataset

The dataset contains customer information including:

  • Customer demographics
  • Account information
  • Internet services
  • Phone services
  • Contract details
  • Payment information

Dataset Details

Attribute Information
Total Records 7043 Customers
Target Variable Churn
Problem Type Binary Classification
Classes Yes / No

๐Ÿ› ๏ธ Technologies Used

Programming Language

  • Python

Libraries

  • Pandas
  • NumPy
  • Matplotlib
  • Seaborn
  • Scikit-Learn
  • Imbalanced Learn (SMOTE)
  • Joblib

Application

  • Streamlit

Development Tools

  • VS Code
  • Jupyter Notebook
  • Git & GitHub

๐Ÿ“ Project Structure

Customer-Churn-Prediction/

โ”‚
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ app.py
โ”‚   โ”œโ”€โ”€ utils.py
โ”‚
โ”œโ”€โ”€ data/
โ”‚   โ””โ”€โ”€ raw/
โ”‚       โ””โ”€โ”€ Telco-Customer-Churn.csv
โ”‚
โ”œโ”€โ”€ models/
โ”‚   โ”œโ”€โ”€ gradient_boosting_model.pkl
โ”‚   โ””โ”€โ”€ preprocessor.pkl
โ”‚
โ”œโ”€โ”€ notebooks/
โ”‚   โ”œโ”€โ”€ 01_data_understanding.ipynb
โ”‚   โ”œโ”€โ”€ 02_eda.ipynb
โ”‚   โ”œโ”€โ”€ 03_preprocessing.ipynb
โ”‚   โ””โ”€โ”€ 04_model_training.ipynb
โ”‚
โ”œโ”€โ”€ reports/
โ”‚   โ””โ”€โ”€ figures/
โ”‚
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ preprocessing.py
โ”‚   โ”œโ”€โ”€ feature_engineering.py
โ”‚   โ”œโ”€โ”€ train.py
โ”‚   โ”œโ”€โ”€ evaluate.py
โ”‚   โ”œโ”€โ”€ predict.py
โ”‚   โ””โ”€โ”€ pipeline.py
โ”‚
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ LICENSE
โ””โ”€โ”€ .gitignore

๐Ÿ” Exploratory Data Analysis

Performed detailed analysis including:

โœ” Churn distribution
โœ” Gender based analysis
โœ” Contract impact
โœ” Internet service effect
โœ” Monthly charges analysis
โœ” Tenure relationship
โœ” Payment method analysis


โš™๏ธ Data Preprocessing

Steps performed:

Missing Value Handling

  • Removed invalid records
  • Converted incorrect data types
  • Fixed missing TotalCharges values

Feature Transformation

Applied:

  • One Hot Encoding
  • Feature Scaling

Class Imbalance Handling

The dataset was imbalanced.

Used:

SMOTE
(Synthetic Minority Oversampling Technique)

Before SMOTE:

No Churn > Churn

After SMOTE:

No Churn = Churn

๐Ÿค– Machine Learning Models

Multiple algorithms were trained:

Model
Logistic Regression
Decision Tree
Random Forest
Gradient Boosting
Histogram Gradient Boosting

After evaluation:

๐Ÿ† Best Model Selected

Gradient Boosting Classifier

๐Ÿ“ˆ Model Performance

Metric Score
Accuracy 77%
ROC-AUC Score 0.84
Precision 0.56
Recall 0.69
F1 Score 0.62

๐Ÿ“Š Evaluation Results

Confusion Matrix

Confusion Matrix


ROC Curve

ROC Curve


๐Ÿ’ป Streamlit Dashboard

The project includes a complete interactive dashboard.

Features:

โœ” Customer information input
โœ” Real-time churn prediction
โœ” Churn probability score
โœ” Customer risk category
โœ” Business recommendations
โœ” Important churn factors
โœ” Customer summary report


Dashboard Preview

Dashboard Dashboard


Prediction Result

Prediction


๐Ÿš€ Installation & Usage

1. Clone Repository

git clone https://github.com/YOUR_USERNAME/Customer-Churn-Prediction.git

Navigate:

cd Customer-Churn-Prediction

2. Create Virtual Environment

python -m venv .venv

Activate:

Windows:

.venv\Scripts\activate

Linux/Mac:

source .venv/bin/activate

3. Install Dependencies

pip install -r requirements.txt

4. Run Application

streamlit run app/app.py

๐ŸŒ Deployment

The application is deployed using Streamlit Cloud.

Deployment workflow:

  1. Source code pushed to GitHub
  2. Streamlit Cloud connected with repository
  3. Python environment configured
  4. Dependencies installed from requirements.txt
  5. Application served using Streamlit

๐Ÿ“Œ Key Features

โœ… Complete Machine Learning Pipeline

โœ… Professional Streamlit Dashboard

โœ… Data Cleaning & Feature Engineering

โœ… Multiple Model Comparison

โœ… SMOTE Class Balancing

โœ… Probability Based Prediction

โœ… Risk Level Classification

โœ… Business Recommendation System

โœ… Interactive User Interface


๐Ÿ”ฎ Future Improvements

  • Deploy application online
  • Add database support
  • Add customer analytics dashboard
  • Improve model accuracy
  • Add Explainable AI using SHAP

๐Ÿ‘จโ€๐Ÿ’ป Developer

Deepak Kumar Jha

AI & Data Science Enthusiast

Skills:

  • Machine Learning
  • Data Science
  • Python Development

โญ Support

If you found this project useful, consider giving it a โญ on GitHub.

Made with โค๏ธ using Python and Machine Learning

Releases

Packages

Contributors

Languages