A comprehensive Machine Learning project that predicts customer churn using multiple ML algorithms, with a beautiful Node.js/React dashboard for visualization and real-time predictions.
- 9+ ML Algorithms: Logistic Regression, Decision Tree, Random Forest, Gradient Boosting, XGBoost, LightGBM, SVM, KNN, Naive Bayes, Neural Network
- Comprehensive Metrics: Accuracy, Precision, Recall, F1-Score, ROC-AUC
- Feature Importance Analysis
- Customer Segmentation Insights
- Interactive Visualizations: Charts, graphs, and tables
- Model Comparison: Side-by-side performance metrics
- ROC Curves: Visual model evaluation
- Confusion Matrices: Detailed prediction analysis
- Live Predictions: Predict churn for new customers
- Customer Insights: Segmentation by subscription, contract, age, gender
- Responsive Design: Works seamlessly across all devices
Customer_Churn_Prediction/
├── Dataset/
│ ├── customer_churn_dataset-training-master.csv
│ └── customer_churn_dataset-testing-master.csv
├── ml_model/
│ ├── train_model.py # ML training pipeline
│ ├── predict.py # Prediction service
│ ├── requirements.txt # Python dependencies
│ ├── models/ # Saved ML models
│ └── results/ # Generated metrics JSON
├── backend/
│ ├── server.js # Express API server
│ └── package.json
├── frontend/
│ ├── src/
│ │ ├── App.js # Main React component
│ │ ├── index.js
│ │ └── index.css # Styling
│ ├── public/
│ └── package.json
├── templates/ # Flask HTML templates
├── static/ # Static assets
├── app.py # Flask application (alternative dashboard)
├── start_servers.ps1 # PowerShell startup script
├── start-servers.bat # Batch startup script
└── README.md
- Python 3.8+
- Node.js 16+ (for React dashboard)
- npm or yarn
cd ml_model
pip install -r requirements.txtcd ml_model
python train_model.pyThis will:
- Train 9+ ML models
- Generate performance metrics
- Save models to
ml_model/models/ - Save dashboard data to
ml_model/results/dashboard_data.json
Step 3A: Start Backend Server
cd backend
npm install
npm startThe API server will run on http://localhost:5000
Step 4A: Start Frontend Dashboard
cd frontend
npm install
npm startThe dashboard will open at http://localhost:3000
Quick Start (PowerShell)
.\start_servers.ps1Quick Start (Command Prompt)
start-servers.batpip install flask flask-cors
python app.pyThe Flask dashboard will run on http://localhost:5000 with integrated UI at /dashboard
The main dashboard displays key metrics and visualizations for churn analysis.
Overview tab with comprehensive visualizations including model accuracy comparison, churn distribution, feature importance, and age-based churn analysis.
Detailed ranking of all 11 ML models with accuracy, precision, recall, F1-score, and ROC-AUC metrics.
Segmentation analysis showing churn patterns by subscription type, contract length, and risk factors.
| Endpoint | Method | Description |
|---|---|---|
/api/health |
GET | Health check |
/api/dashboard |
GET | All dashboard data |
/api/stats |
GET | Dataset statistics |
/api/models |
GET | Model results & ranking |
/api/roc-curves |
GET | ROC curve data |
/api/confusion-matrices |
GET | Confusion matrices |
/api/feature-importance |
GET | Feature importance |
/api/segments |
GET | Customer segments |
/api/churn-factors |
GET | Churn risk factors |
/api/predict |
POST | Predict customer churn |
- Dataset statistics cards
- Model accuracy comparison chart
- Churn distribution pie chart
- Feature importance ranking
- Age group churn analysis
- Full model ranking table
- Multi-metric bar charts
- ROC curves overlay
- Confusion matrices for top models
- Churn by subscription type
- Churn by contract length
- Churn risk factors analysis
- Gender-based segmentation
- Interactive prediction form
- Model selection dropdown
- Real-time churn prediction
- Risk level classification
- ML Pipeline: Python, Scikit-learn, XGBoost, LightGBM
- Backend: Node.js, Express.js
- Frontend: React, Recharts
- Styling: Custom CSS
| Feature | Type | Description |
|---|---|---|
| CustomerID | Numeric | Unique identifier |
| Age | Numeric | Customer age |
| Gender | Categorical | Male/Female |
| Tenure | Numeric | Months with company |
| Usage Frequency | Numeric | Service usage frequency |
| Support Calls | Numeric | Number of support calls |
| Payment Delay | Numeric | Payment delay in days |
| Subscription Type | Categorical | Basic/Standard/Premium |
| Contract Length | Categorical | Monthly/Quarterly/Annual |
| Total Spend | Numeric | Total amount spent |
| Last Interaction | Numeric | Days since last interaction |
| Churn | Target | 0 = Stayed, 1 = Churned |
Models are automatically ranked by accuracy. Typical results include:
- Best models usually achieve 85-90%+ accuracy
- Feature importance helps identify key churn predictors
- ROC-AUC scores indicate model discrimination ability
This project is for educational purposes.



