You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AI-powered OTT customer churn prediction and retention intelligence system
ChurnIQ Pro goes beyond basic churn prediction β it tells you WHO will churn, WHY they will churn, and WHAT TO DO about it, all in real time through a professional analytics dashboard.
Returns subject line, email body, 2 business actions, suggested offer
Rule-based fallback if Gemini is unavailable
Sent live via Gmail SMTP directly from the dashboard
Interactive Dashboard
KPI cards: Total customers, High risk count, Revenue at risk, Avg churn %
Churn trend line chart, Reasons donut chart, Plan type bar chart
Sortable, filterable customer risk table with color-coded risk badges
What-if simulator: move sliders β live churn % recalculation
Segment analysis: by plan, device, tenure, genre
Light / Dark mode toggle
Tech Stack
Machine Learning
Tool
Purpose
Python
Core language
XGBoost
Gradient boosting classifier
SHAP
Explainable AI (Shapley values)
Scikit-learn
Preprocessing, metrics, train-test split
imbalanced-learn
SMOTE for class balancing
Pandas + NumPy
Data manipulation
Faker
Synthetic dataset generation
Matplotlib + Seaborn
EDA visualization
Backend
Tool
Purpose
FastAPI
REST API framework
Uvicorn
ASGI server
Pydantic
Request/response validation
Google Gemini API
AI retention email generation
Gmail SMTP
Live email delivery
Frontend
Tool
Purpose
React 18
UI framework
Vite
Build tool
Tailwind CSS
Utility-first styling
Recharts
Data visualization charts
React Router v6
Client-side routing
Lucide React
Icons
Deployment
Service
Purpose
Render
Backend hosting (free tier)
Vercel
Frontend hosting (free tier)
GitHub
Version control + CI/CD
π Project Structure
ChurnIQ/
βββ churniq_ml_pipeline.py # Complete ML pipeline (Parts AβH)
βββ main.py # FastAPI backend + Gemini + Email
βββ requirements.txt # Python dependencies
βββ runtime.txt # Python version for Render
βββ add_emails.py # Setup script for demo customer
βββ fix_cust99999.py # Adds demo customer to predictions
βββ ott_churn_dataset.csv # Synthetic OTT dataset (5000 rows)
βββ customer_predictions.csv # Precomputed predictions + SHAP reasons
βββ churniq_model.pkl # Trained XGBoost model
βββ feature_names.pkl # Feature column names for inference
βββ frontend/
βββ src/
β βββ App.jsx # Main layout + routing + dark mode
β βββ api/churniq.js # All API calls
β βββ pages/
β βββ Dashboard.jsx
β βββ RiskTable.jsx
β βββ CustomerDetail.jsx
β βββ SegmentAnalysis.jsx
β βββ ChurnPredict.jsx
βββ package.json
βββ vite.config.js
βοΈ ML Pipeline (churniq_ml_pipeline.py)
Part A β Synthetic Dataset Generation (5000 OTT customers, 21 features)
Part B β Exploratory Data Analysis (6-chart EDA dashboard)
Part C β Preprocessing (encoding, feature engineering)
Part D β SMOTE (class imbalance fix, train only)
Part E β XGBoost Training (200 trees, depth 5, lr 0.1)
Part F β Model Evaluation (ROC-AUC, confusion matrix)
Part G β SHAP (global + per-customer explanations)
Part H β Predictions Table (churn_prob + top 3 SHAP reasons)
π API Endpoints
Method
Endpoint
Description
GET
/
Health check
GET
/customers
Full risk table + KPI summary
GET
/customer/{id}
Single customer detail + SHAP
POST
/whatif
Live what-if simulation
GET
/retention/{id}
Gemini AI email + actions
GET
/segments
Churn stats by segment
GET
/dashboard/summary
All KPIs in one call
POST
/send-email
Send retention email via Gmail
GET
/email-status
Check email configuration
Local Setup
1. Clone the repo
git clone https://github.com/Kd1880/ChurnIQ.git
cd ChurnIQ
2. Install Python dependencies
pip install -r requirements.txt
3. Run ML pipeline (generates dataset + trains model)
python churniq_ml_pipeline.py
4. Configure environment
# Set your Gemini API keyset GEMINI_API_KEY=your_key_here # Windowsexport GEMINI_API_KEY=your_key_here # Mac/Linux# Set up demo customer + Gmail (optional)
python add_emails.py