Skip to content

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Customer Churn Analysis

An end-to-end Python analytics case study that examines customer churn patterns using data-quality checks, exploratory segmentation, visualization, and interpretable predictive modeling.

The project uses a fully synthetic dataset and contains no real customer, employer, or confidential business information.

Project Overview

Customer churn can affect recurring revenue, acquisition efficiency, and long-term customer value. This project demonstrates a reproducible workflow for:

  • Assessing dataset quality
  • Cleaning and validating customer records
  • Comparing churn across customer segments
  • Visualizing churn-rate differences
  • Building an interpretable logistic-regression model
  • Translating analytical results into business-focused findings

Dataset

The dataset contains 800 synthetic customer records and 14 columns covering:

  • Customer tenure
  • Monthly and total charges
  • Contract type
  • Internet service
  • Payment method
  • Support tickets
  • Late payments
  • Satisfaction score
  • Automatic payment enrollment
  • Paperless billing
  • Senior-citizen indicator
  • Churn outcome

The observed churn rate in the synthetic dataset is 20.38%.

Key Findings

  • Month-to-month customers had the highest contract-level churn rate at 26.25%.
  • Electronic-check customers had the highest payment-method churn rate at 30.86%.
  • Strong positive model signals included month-to-month contracts, electronic-check payments, fiber-optic service, total charges, and recent support tickets.

These findings demonstrate analytical methods on synthetic data and should not be interpreted as causal evidence about real customers.

Model Results

A logistic-regression pipeline was trained with:

  • Median imputation for numeric values
  • Most-frequent imputation for categorical values
  • Standard scaling for numeric features
  • One-hot encoding for categorical features
  • A stratified 75/25 train-test split
  • Balanced class weights
Metric Result
Accuracy 0.7450
Precision 0.4265
Recall 0.7073
ROC AUC 0.8237

The model is intended to demonstrate an interpretable portfolio workflow, not production deployment.

Repository Structure

python-customer-churn-analysis/
├── data/
│   ├── customer_churn.csv
│   └── README.md
├── outputs/
│   └── executive_summary.md
├── src/
│   └── analyze_churn.py
├── .gitignore
├── LICENSE
├── README.md
└── requirements.txt

Analysis Workflow

The script:

  1. Loads and validates the dataset.
  2. Removes duplicate customer identifiers.
  3. Converts numeric fields safely.
  4. Creates a column-level data-quality report.
  5. Calculates churn rates by contract, internet service, and payment method.
  6. Saves segment-level charts and summary tables.
  7. Trains and evaluates a logistic-regression model.
  8. Extracts model coefficients for interpretation.
  9. Produces an executive summary.

Run Locally

Clone the repository and install the dependencies:

git clone https://github.com/JashvanthiPriyanka2910/python-customer-churn-analysis.git
cd python-customer-churn-analysis
pip install -r requirements.txt

Run the analysis:

python src/analyze_churn.py

The script creates an outputs directory containing:

  • Data-quality results
  • Segment-level churn tables
  • Churn-rate charts
  • Model metrics
  • Confusion matrix
  • Model feature effects
  • Executive summary

Technologies

  • Python
  • pandas
  • NumPy
  • Matplotlib
  • scikit-learn

Skills Demonstrated

  • Data cleaning and validation
  • Exploratory data analysis
  • Customer segmentation
  • Business KPI interpretation
  • Data visualization
  • Feature preprocessing
  • Classification modeling
  • Model evaluation
  • Reproducible analysis workflows
  • Executive communication

Limitations

  • The dataset is synthetic.
  • The analysis shows association, not causation.
  • The model has not been externally validated.
  • No production monitoring, deployment, or fairness assessment is included.
  • Results should not be used to make decisions about real individuals.

Responsible Use

This repository is a portfolio demonstration. It contains no employer-confidential data, internal system information, real customer records, or personally identifiable information.

Author

Jashvanthi Priyanka

LinkedIn

About

Python analytics case study exploring customer churn drivers through data cleaning, visualization, and predictive modeling.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages