Download README.md from raymuz/Customer_Churn_Intelligence_Lab: direct link, hf CLI and curl.
- Browser
- Download file 4.41 kB
-
https://huggingface.co/spaces/raymuz/Customer_Churn_Intelligence_Lab/resolve/main/README.md
- Command line
-
hf download hf://spaces/raymuz/Customer_Churn_Intelligence_Lab/README.md
-
curl -L -o README.md https://huggingface.co/spaces/raymuz/Customer_Churn_Intelligence_Lab/resolve/main/README.md
title: Churn Intelligence Lab
emoji: π
colorFrom: blue
colorTo: indigo
sdk: docker
app_port: 7860
pinned: false
Churn Intelligence Lab β dual-industry ML portfolio
Live demo: A Docker-hosted Gradio + FastAPI application with two separately trained models.
How it works: Bank and telecom customer profiles β in-pipeline imputation/encoding β classifier β thresholded churn screening score.
Evaluated results (held-out 20% test partition)
| Dataset | Records after dedup | Selected model | ROC AUC | PR AUC | Precision | Recall | F2 | Threshold | Status |
|---|---|---|---|---|---|---|---|---|---|
| Bank | 10,000 | XGBoost | 0.858 | 0.703 | 0.440 | 0.813 | 0.695 | 0.425 | demonstration |
| Telecom | 5,880 | XGBoost | 0.480 | 0.471 | 0.493 | 1.000 | 0.830 | 0.100 | research_only_low_signal |
Evaluation protocol: 64/16/20 train/validation/test stratified splits, fixed random seed, model selection on validation PR AUC; the F2 classification threshold is selected on validation only. The test set remains untouched until final scoring. XGBoost uses training-only 3-fold randomized hyperparameter search.
Architecture
train.py β models/{bank,telecom}_churn.joblib + model_metadata.json β app.py β Docker Space (port 7860) β Gradio UI at /ui/ + FastAPI Swagger at /docs.
Public API
GET /health: readiness and loaded modelsGET /api/metadata: columns, chosen model, test metricsPOST /api/predict/bankor/api/predict/telecom:{"data": {...feature name/value pairs...}}POST /api/predict-batch/bankor/api/predict-batch/telecom:{"records": [{...}, {...}]}(max 100)
Sample request (generated safely from defaults in model metadata):
import json, requests
metadata = json.load(open('model_metadata.json'))['datasets']['bank']
payload = {'data': metadata['defaults']}
response = requests.post('https://YOUR-SPACE.hf.space/api/predict/bank', json=payload, timeout=20)
print(response.json())
Reproduce model training
- Use the Python minor version in the notebook-generated
Dockerfile(andmodel_metadata.jsonwhen published). Install:pip install -r requirements.txt matplotlib. - Supply
bank_customer_churn.csvandcustomer_churn_data.csvlocally, never publish raw customer rows. python train.py --data-dir /path/to/datasets --project-dir . --tuning-iterations 6.python -m pytest -q tests/;uvicorn app:app --host 0.0.0.0 --port 7860.- Visit
http://localhost:7860/ui/andhttp://localhost:7860/docs.
Evaluation visualizations
Bank ROC (held-out test)
Bank feature importance (validation permutation)
Telecom ROC (near-chance baseline)
Project layout
train.pyβ full reusable training and model comparison pipelineapp.pyβ UI + validated REST endpointsmodels/β two trained, serialized sklearn-compatible pipelinesreports/β comparison CSV, permutation importance, ROC and confusion matrix graphicsmodel_metadata.jsonβ measured performance, feature defaults, auditstests/β API smoke testsDockerfile,requirements.txtβ reproducible runtimeMODEL_CARD.mdβ model/data limitations and ethics notesnotebooks/Customer_Churn_Training_Walkthrough.ipynbβ standalone training walkthrough runnable in Colab.github/workflows/ci.ymlβ GitHub Actions CI smoke test
Limitations and responsible use
Scores are uncalibrated probabilities and are not guarantees. A model with near-chance held-out discrimination is flagged research_only_low_signal, and its API refuses actionable churn labels. Demonstration datasets may be artificial/educational and do not prove real-world performance; monitor data drift, assess geographic/demographic fairness, calibrate before operational use, and obtain appropriate consent and privacy reviews. The public demo is for synthetic or anonymized inputs, with no storage of uploaded customer records as a product feature. Do not submit personal data or use this demo to make automated decisions about people.
Built in a single Colab notebook from the attached deployment and containerization case studies. All reported results are computed, not estimated.


