A complete end-to-end churn prediction pipeline combining SQL, Python (ML), and Power BI to identify at-risk telecom customers and visualize actionable insights.
Customer churn is one of the most critical problems in the telecom industry. This project builds a full-stack churn analysis system that:
- Ingests & cleans raw customer data using SQL Server
- Trains ML models (Logistic Regression, Random Forest, XGBoost) in Python to predict churn
- Visualizes churn trends and predicted churners through an interactive Power BI dashboard
SQL Server ──► Python (ML) ──► Power BI Dashboard
│ │ │
│ Data cleaning │ Model training │ Churn summary
│ & staging │ & prediction │ & forecasting
churn-prediction-system/
│
├── data/
│ └── Customer_Data.csv # Raw customer dataset
│
├── notebooks/
│ └── churn_prediction_model.ipynb # ML model training (LR, RF, XGBoost)
│
├── sql/
│ └── churn_queries.sql # Data exploration, cleaning & views
│
├── powerbi/
│ └── ChurnAnalysis.pbix # Power BI dashboard file
│
├── docs/
│ └── Power_Query_and_DAX.md # Power Query steps & DAX measures
│
├── assets/
│ └── images/ # Dashboard screenshots & icons
│ ├── Summary.PNG
│ └── Prediction.PNG
│
├── requirements.txt
├── .gitignore
└── README.md
| Layer | Tools |
|---|---|
| Data Storage | SQL Server |
| Data Processing | SQL (T-SQL) |
| Machine Learning | Python, scikit-learn, XGBoost |
| Visualization | Power BI |
| Environment | Jupyter Notebook / Anaconda |
Run the queries in sql/churn_queries.sql in the following order:
- Data Exploration — check distinct values and null counts in
stg_Churn - Data Cleaning — replace nulls and load clean data into
prod_Churn - Create Views — create
vw_ChurnDataandvw_JoinDatafor Power BI
Install dependencies:
pip install -r requirements.txtRun the notebook:
Open notebooks/churn_prediction_model.ipynb in Jupyter Notebook and run all cells.
The notebook covers:
- Data loading and label encoding
- Train/test split (80/20)
- Training and evaluating three models:
- Logistic Regression
- Random Forest (200 estimators)
- XGBoost (300 estimators, learning rate 0.05)
- Exporting predictions for Power BI
Open powerbi/ChurnAnalysis.pbix in Power BI Desktop.
Power Query transformations and all DAX measures are documented in docs/Power_Query_and_DAX.md.
Summary Page
Churn Prediction Page
Three classification models were trained and compared on the customer dataset:
| Model | Notes |
|---|---|
| Logistic Regression | Baseline model |
| Random Forest | 200 estimators, best interpretability |
| XGBoost | 300 estimators, highest accuracy |
The dataset (data/Customer_Data.csv) contains customer-level telecom data including demographics, services subscribed, billing information, and churn status.
Key columns: Customer_ID, Gender, Age, Tenure_in_Months, Internet_Service, Contract, Monthly_Charge, Total_Revenue, Customer_Status
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
This project is for educational and portfolio purposes.