CoolFace
Apppublic

pranav-singh-developer-1/telecom-churn-predictor

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes
App README

๐Ÿ“‰ AI Customer Churn Intelligence (Milestone 1)

This repository contains the Mid-Semester submission for the Customer Churn Prediction & Agentic Retention Strategy project.

Phase 1 focuses entirely on building a robust, production-ready predictive analytics system using Traditional Machine Learning. It analyzes historical behavioral data to identify customers at risk of canceling their service.


๐Ÿš€ State-of-the-Art (SOTA) Features

To move beyond basic templates, this pipeline implements several advanced ML techniques:

๐Ÿ” Explainable AI (XAI)

Mathematically extracts feature weights to explain why a customer is churning (e.g., high customer service calls), rather than just outputting a black-box probability.

๐ŸŽฏ Cost-Sensitive Threshold Tuning

Optimizes the decision boundary from the default 50% to a custom 30% threshold, prioritizing detection of high-risk customers over raw accuracy.

โš–๏ธ SMOTE Integration

Utilizes the imbalanced-learn library to generate synthetic data for the minority class (churners), ensuring the Logistic Regression model learns balanced behavioral patterns.

๐Ÿงฉ Custom Scikit-Learn Pipelines

Encapsulates data cleaning, dynamic StandardScaler scaling, and OneHotEncoder categorical handling directly into the model artifact.


๐Ÿ“ Repository Architecture

The codebase follows industry-standard modular design for machine learning projects:

text
churn_project/
โ”œโ”€โ”€ data/                  # Ignored in version control
โ”‚   โ””โ”€โ”€ raw/               # Location for telecom_churn.csv
โ”œโ”€โ”€ models/                
โ”‚   โ””โ”€โ”€ churn_model.pkl    # Serialized ML pipeline artifact
โ”œโ”€โ”€ src/                   # Core engine logic
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ data_loader.py     # Data validation script
โ”‚   โ”œโ”€โ”€ preprocessing.py   # Custom Scikit-Learn Transformer
โ”‚   โ””โ”€โ”€ train_model.py     # Pipeline construction and training
โ”œโ”€โ”€ app.py                 # Gradio + Plotly interactive UI
โ”œโ”€โ”€ requirements.txt       # Pinned dependencies for reproducible builds
โ””โ”€โ”€ README.md              # Project documentation

๐Ÿ› ๏ธ Setup & Execution Instructions

Follow the steps below to reproduce the full training and deployment workflow.


1๏ธโƒฃ Environment Setup

Clone the repository and install dependencies:

bash
git clone https://github.com/Pranav-Singh-Devloper/telecom_churn_prediction.git
cd telecom_churn_prediction
pip install -r requirements.txt

It is recommended to use a virtual environment:

bash
python -m venv venv
source venv/bin/activate   # On macOS/Linux
venv\Scripts\activate      # On Windows

2๏ธโƒฃ Data Preparation

  1. 1.Download the Telecom Churn dataset.
  2. 2.Rename the dataset file to:
telecom_churn.csv
  1. 1.Place it inside:
data/raw/

Expected structure:

data/
โ””โ”€โ”€ raw/
    โ””โ”€โ”€ telecom_churn.csv

3๏ธโƒฃ Train the Model

Run the training pipeline:

bash
python src/train_model.py

This will:

  • โ€”Apply preprocessing and feature engineering
  • โ€”Perform SMOTE-based class balancing
  • โ€”Train the Logistic Regression model
  • โ€”Optimize the classification threshold
  • โ€”Generate explainability metrics
  • โ€”Serialize the trained pipeline

After successful execution, the following file will be created:

models/churn_model.pkl

4๏ธโƒฃ Launch the Interactive Dashboard

Start the Gradio application:

bash
python app.py

Then open your browser and navigate to:

http://127.0.0.1:7860

The dashboard allows you to:

  • โ€”Input customer attributes
  • โ€”Generate churn probability predictions
  • โ€”View explainability insights
  • โ€”Interactively analyze risk factors

๐Ÿ” Complete Workflow Summary

  1. 1.Install dependencies
  2. 2.Place dataset in data/raw/
  3. 3.Train model (train_model.py)
  4. 4.Launch UI (app.py)

Your churn intelligence system is now fully operational.