Customer churn is a critical challenge for subscription-based businesses.
This project builds an end-to-end machine learning pipeline to predict customer churn and identify key factors contributing to customer attrition.
The goal is to help businesses proactively retain customers by using data-driven insights.
This project uses separate training and testing datasets to ensure proper model evaluation.
- Analyze customer behavior and churn patterns
- Perform exploratory data analysis (EDA)
- Engineer and preprocess features
- Build and compare machine learning models
- Evaluate models using appropriate metrics
- Derive actionable business insights
- Two datasets are used in this project:
customer_churn_dataset-training-master.csvcustomer_churn_dataset-testing-master.csv
- The datasets contain customer demographic, subscription, and usage information
- Target variable: Churn (1 = Churned, 0 = Retained)
- Includes both numerical and categorical features
- Python - Programming Language
- Pandas & NumPy – Data manipulation
- Matplotlib & Seaborn – Data visualization
- Scikit-learn – Machine learning models & evaluation
Key analyses performed:
- Churn distribution analysis
- Churn rate by contract length
- Feature correlation analysis
- Identification of high-risk customer segments
- Converted categorical variables into numerical format using one-hot encoding
- Standardized numerical features to ensure consistent model performance
- Split data into training, validation, and testing sets for reliable evaluation
- Ensured feature consistency between training and testing datasets after encoding
- Logistic Regression
- Random Forest Classifier
Both models were evaluated and compared using:
- Accuracy
- Precision
- Recall
- ROC-AUC Score
- Confusion Matrix
- ROC Curve Visualization
- ROC curves were plotted for model comparison
- Random Forest achieved a strong predictive performance
- Feature importance analysis highlighted key churn drivers
- Customers with short-term or month-to-month contracts show higher churn rates
- Certain subscription types are more prone to churn
- Contract duration and service usage play a major role in retention
This project demonstrates how machine learning can be applied to:
- Predict customer churn effectively
- Identify high-risk customers
- Support business decisions with actionable insights
-
Clone the repository
-
Install required libraries:
pip install pandas numpy matplotlib seaborn scikit-learn
-
Open the notebook:
Customer Churn Prediction.ipynb
-
Ensure the following files are in the same directory:
- customer_churn_dataset-training-master.csv
- customer_churn_dataset-testing-master.csv
-
Run all cells sequentially
LinkedIn : https://www.linkedin.com/in/soundharyaiyer09
Github : https://github.com/Soundharya09