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.
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
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%.
- 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.
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.
python-customer-churn-analysis/
├── data/
│ ├── customer_churn.csv
│ └── README.md
├── outputs/
│ └── executive_summary.md
├── src/
│ └── analyze_churn.py
├── .gitignore
├── LICENSE
├── README.md
└── requirements.txt
The script:
- Loads and validates the dataset.
- Removes duplicate customer identifiers.
- Converts numeric fields safely.
- Creates a column-level data-quality report.
- Calculates churn rates by contract, internet service, and payment method.
- Saves segment-level charts and summary tables.
- Trains and evaluates a logistic-regression model.
- Extracts model coefficients for interpretation.
- Produces an executive summary.
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.txtRun the analysis:
python src/analyze_churn.pyThe 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
- Python
- pandas
- NumPy
- Matplotlib
- scikit-learn
- 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
- 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.
This repository is a portfolio demonstration. It contains no employer-confidential data, internal system information, real customer records, or personally identifiable information.
Jashvanthi Priyanka