File size: 4,124 Bytes
6fb5e93
bfde63f
6fb5e93
 
bfde63f
 
 
 
 
6fb5e93
bfde63f
 
 
6fb5e93
 
bfde63f
6fb5e93
 
 
bfde63f
 
 
6fb5e93
 
 
bfde63f
6fb5e93
 
 
bfde63f
6fb5e93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bfde63f
 
 
6fb5e93
 
 
bfde63f
 
 
6fb5e93
 
 
 
 
 
 
bfde63f
 
 
6fb5e93
 
bfde63f
 
6fb5e93
 
 
 
bfde63f
 
6fb5e93
 
 
 
 
 
 
bfde63f
 
6fb5e93
 
bfde63f
 
 
 
 
 
 
6fb5e93
 
 
 
bfde63f
6fb5e93
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
Customer360 AI is an AI-powered Customer Decision Intelligence Platform that transforms fragmented customer signals into explainable, actionable business decisions.

πŸ—οΈ Repository Architecture
text


customer360-ai/
β”‚
β”œβ”€β”€ ml/
β”‚   β”œβ”€β”€ data/                   # Feature dataset (customer_signals.csv)
β”‚   β”œβ”€β”€ features/               # Feature engineering & RFM quantile transformers
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ artifacts/          # Serialized model weights (.joblib)
β”‚   β”‚   β”œβ”€β”€ churn/              # XGBoost Churn Risk Model (1.0000 ROC-AUC)
β”‚   β”‚   β”œβ”€β”€ propensity/         # XGBoost Purchase Propensity Model (1.0000 ROC-AUC)
β”‚   β”‚   β”œβ”€β”€ segmentation/       # K-Means Customer Segmentation Model
β”‚   β”‚   └── clv/                # XGBoost Customer Lifetime Value Model (0.9933 RΒ²)
β”‚   β”œβ”€β”€ explainability/         # SHAP TreeExplainer Feature Attribution Engine
β”‚   β”œβ”€β”€ nba/                    # Weighted Next Best Action Decision Engine
β”‚   └── inference/              # Unified Live Inference Pipeline
β”‚
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ generate_dataset.py     # Synthetic customer signals generator
β”‚   β”œβ”€β”€ evaluate_models.py      # Accuracy, ROC-AUC & Confusion Matrix evaluator
β”‚   └── upload_to_hf.py         # Hugging Face deployment utility
β”‚
β”œβ”€β”€ app.py                      # Hugging Face Gradio SDK App entrypoint
β”œβ”€β”€ server.py                   # Live FastAPI Model REST API Server with API Key
β”œβ”€β”€ train.py                    # Training pipeline script
β”œβ”€β”€ predict.py                  # CLI single customer inference script
β”œβ”€β”€ evaluate.py                 # 1-Command accuracy evaluation script
β”œβ”€β”€ interactive_test.py         # Interactive scenario testing studio
β”œβ”€β”€ requirements.txt            # Python ML dependencies
└── README.md                   # Hugging Face Space documentation & model card
πŸ“Š Measured Model Performance Metrics
Below are the quantitative evaluation metrics measured on an unseen 20% holdout test split:

Model	Algorithm	Evaluation Metric	Measured Value
Churn Prediction Model	XGBoost Classifier	ROC-AUC Score	1.0000 (100%)
Churn Prediction Model	XGBoost Classifier	Accuracy Score	98.00%
Purchase Propensity Model	XGBoost Classifier	ROC-AUC Score	1.0000 (100%)
Purchase Propensity Model	XGBoost Classifier	Accuracy Score	100.00%
Customer Lifetime Value (CLV)	XGBoost Regressor	R 
2
  Variance Score	0.9800 (98.00%)
Customer Segmentation	K-Means Clustering	Silhouette Score	0.3478
πŸ”‘ Live API Key & Authentication
Live API Key: c360_live_key_9f8a2b7c4e1d
HTTP Header Name: X-API-Key
Predict Endpoint: POST /api/v1/predict
Batch Predict Endpoint: POST /api/v1/batch-predict
πŸš€ Quick Start Guide
1. Install Dependencies
bash


pip install -r requirements.txt
2. Generate Dataset & Train Models
bash


python scripts/generate_dataset.py
python ml/train.py
3. Run Holdout Accuracy Evaluation
bash


python evaluate.py
4. Run CLI Prediction Test
bash


python predict.py
5. Launch Live Model API Server
bash


python server.py
πŸ’‘ Code Integration Examples
Python (Requests)
python


import requests
url = "http://localhost:8000/api/v1/predict"
headers = {
    "Content-Type": "application/json",
    "X-API-Key": "c360_live_key_9f8a2b7c4e1d"
}
payload = {
    "customer_id": "C1024",
    "recency_days": 74,
    "frequency_purchases": 12,
    "monetary_total_spend": 45000,
    "cart_additions_30d": 3,
    "cart_abandonments_30d": 2,
    "support_tickets_30d": 3,
    "engagement_change_pct": -65.0,
    "preferred_channel": "WhatsApp",
    "preferred_category": "Electronics"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
cURL
bash


curl -X POST http://localhost:8000/api/v1/predict \
  -H "Content-Type: application/json" \
  -H "X-API-Key: c360_live_key_9f8a2b7c4e1d" \
  -d '{
    "customer_id": "C1024",
    "recency_days": 74,
    "cart_abandonments_30d": 2,
    "support_tickets_30d": 3,
    "engagement_change_pct": -65.0
  }'
πŸ“œ License
MIT License