Skip to content

Predicts telecom customer churn with machine learning and an interactive Streamlit app. Features include single/batch predictions, dashboards, and actionable insights for improved retention.

License

Notifications You must be signed in to change notification settings

DataStatsMohith/customer-churn-prediction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Customer Churn Prediction Project

πŸ“‹ Overview

This project focuses on predicting customer churn for a telecom company using the Telco Customer Churn Dataset. By leveraging machine learning models, it identifies key factors contributing to churn and provides actionable insights to help businesses improve customer retention.

The project includes:

  • End-to-end workflows for data preprocessing, model training, and optimization.
  • An interactive Streamlit app with features like single prediction, batch processing, and dashboard visualizations.

πŸ“‘ Table of Contents

  1. Overview
  2. Live Demo
  3. Objectives
  4. Project Workflow
  5. Key Insights and Results
  6. How to Run Locally
  7. Repository Structure
  8. Future Work
  9. License

🌐 Live Demo

Explore the deployed app here: Customer Churn Prediction App

This interactive app provides:

  • Single Customer Prediction: Predict churn for a single customer based on key features.
  • Batch Prediction: Upload a CSV file containing multiple customer records to generate predictions for the entire batch.
  • Dashboards: Visualize key insights, such as churn rates, feature correlations, and demographic trends.

🎯 Objectives

  1. Understand the factors influencing customer churn using data analysis and visualization.
  2. Develop a machine learning model to predict churn with high accuracy and interpretability.
  3. Provide business insights through interactive dashboards and actionable KPIs.

πŸ› οΈ Project Workflow

Data Preprocessing

  • Handled missing values and inconsistent data (e.g., TotalCharges column).
  • Encoded categorical features using LabelEncoder.
  • Scaled numerical features like tenure, MonthlyCharges, and TotalCharges using StandardScaler.

Model Training and Optimization

  • Trained multiple models (Logistic Regression, Random Forest) and optimized them using GridSearchCV.
  • Selected the best-performing model based on metrics like accuracy, F1-score, and AUC-ROC.
  • Tuned decision thresholds for improved business interpretability using a custom optimal threshold.

App Deployment

  • Built an interactive Streamlit app with the following features:
    • Single Customer Prediction: Allows users to predict churn for a single customer.
    • Batch Prediction: Enables predictions for multiple customers through CSV upload.
    • Dashboard: Visualizes key insights like churn rates, feature correlations, and demographic trends.

πŸ“Š Key Insights and Results

Key Performance Indicators (KPIs):

KPIs

  • Total Customers: 7043
  • Churned Customers: 2648
  • Churn Rate: 37.60%

Visualizations

1. Churn Prediction Distribution

Churn Prediction Distribution

The churn rate is approximately 37.60%, with a significant proportion of customers predicted not to churn.

2. Churn Rate by Contract Type

Churn Rate by Contract Type

Month-to-month contracts have the highest churn rate, indicating potential issues with short-term customer retention.

3. Churn Rate by Gender

Churn Rate by Gender

Female customers have a slightly higher churn rate compared to male customers.

4. Churn Rate by Tenure

Churn Rate by Tenure

Customers with longer tenures are less likely to churn, emphasizing the importance of customer retention strategies.

5. Monthly Charges Distribution

Monthly Charges Distribution by Churn

Churned customers tend to have higher monthly charges, suggesting pricing strategy adjustments for high-value customers.

6. Feature Correlations

Feature Correlations

Key insights:

  • Tenure has a negative correlation with churn.
  • MonthlyCharges and TotalCharges show a moderate positive correlation with churn.

πŸ–₯️ How to Run Locally

Prerequisites

  • Python 3.8 or higher
  • Install dependencies listed in requirements.txt

Steps

  1. Clone the repository:

    git clone https://github.com/DataStatsMohith/customer-churn-prediction.git
    
  2. Navigate to the directory:

    cd customer-churn-prediction
  3. Install dependencies:

    pip install -r requirements.txt
  4. Run the Streamlit app:

    streamlit run app/app.py

πŸ“‚ Repository Structure

customer-churn-prediction/
β”‚
β”œβ”€β”€ app/                            # Streamlit app
β”‚   └── app.py
β”‚
β”œβ”€β”€ assets/                         # Visualizations and animations
β”‚   β”œβ”€β”€ *.png                       # Images for dashboards
β”‚   └── animations/                 # JSON animations for Streamlit
β”‚
β”œβ”€β”€ data/                           # Dataset and preprocessed files
β”‚   β”œβ”€β”€ WA_Fn-UseC_-Telco-Customer-Churn.csv
β”‚   β”œβ”€β”€ feature_columns.pkl
β”‚   β”œβ”€β”€ final_churn_model.pkl
β”‚   β”œβ”€β”€ label_encoders.pkl
β”‚   β”œβ”€β”€ optimal_threshold.pkl
β”‚   └── scaler.pkl
β”‚
β”œβ”€β”€ notebooks/                      # Jupyter notebook(s)
β”‚   └── FinalCustomer_Churn_Prediction.ipynb
β”‚
β”œβ”€β”€ README.md                       # Project documentation
β”œβ”€β”€ requirements.txt                # Python dependencies
└── LICENSE                         # Project license (optional)

πŸš€ Future Work

  • Model Improvements: Experiment with deep learning models for better performance.
  • Additional Features: Incorporate customer satisfaction scores and support interactions.
  • Deployment: Extend the app deployment to cloud platforms like AWS or Heroku.

πŸ“œ License

This project is licensed under the MIT License.


About

Predicts telecom customer churn with machine learning and an interactive Streamlit app. Features include single/batch predictions, dashboards, and actionable insights for improved retention.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published