debjit-coder commited on
Commit
96049b4
·
verified ·
1 Parent(s): e411357

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +140 -0
README.md ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ tags:
4
+ - tabular-classification
5
+ - lightgbm
6
+ - xgboost
7
+ - ensemble
8
+ - waterborne-disease
9
+ - early-warning-system
10
+ ---
11
+
12
+ # ArogyaJal Early Warning System for Waterborne Disease Outbreaks
13
+
14
+ ## Model Description
15
+
16
+ The **ArogyaJal Early Warning System v2.0** is a production-grade machine learning model designed to predict waterborne disease outbreaks. Developed by the ML Engineering Team, this system provides early alerts for potential outbreaks, enabling timely interventions and safeguarding public health. It is built upon an ensemble of LightGBM and XGBoost classifiers, trained on a large-scale dataset from 50 villages over a 730-day period.
17
+
18
+ ## Problem Formulation
19
+
20
+ The model addresses a **binary classification task**: predicting whether the 7-day forward sum of reported cases of waterborne diseases will be greater than or equal to 3 (indicating an outbreak). This formulation allows for clear, actionable alerts.
21
+
22
+ ## Dataset
23
+
24
+ The model was trained and validated on a comprehensive dataset with the following key characteristics:
25
+
26
+ * **Total Observations**: 36,200 samples
27
+ * **Number of Villages**: 50
28
+ * **Date Range**: January 1, 2023, to December 24, 2024
29
+ * **Class Imbalance**: 72.0% negative (no outbreak), 28.0% positive (outbreak), reflecting a realistic 2.57:1 imbalance ratio.
30
+ * **Validation**: Panel-Safe Stratified time-based validation was used to ensure robustness and prevent temporal leakage.
31
+
32
+ ## Feature Engineering
33
+
34
+ The model utilizes 44 strictly causal features, engineered through a highly optimized, vectorized pipeline. These features capture critical information from IoT sensor data and reported cases, including:
35
+
36
+ * Missingness indicators
37
+ * Imputed IoT features
38
+ * Temporal lags (t-1, t-3, t-7, t-14) for IoT parameters and reported cases
39
+ * Rolling statistics (7-day and 14-day mean/std) for turbidity and reported cases
40
+ * 3-day rate of change (derivatives) for pH, turbidity, TDS, and conductivity
41
+ * Cyclical seasonal features (sin/cos of day of year)
42
+ * Water quality composite score
43
+ * Interaction features (`turb_x_cases_lag1`, `ph_deviation`, `tds_x_turb`)
44
+ * Cumulative burden (7-day and 14-day rolling sum of reported cases)
45
+
46
+ ## Model Architecture
47
+
48
+ The final production model is a **weighted ensemble** of two Optuna-tuned gradient boosting models:
49
+
50
+ * **LightGBM Binary Classifier**
51
+ * **XGBoost Binary Classifier**
52
+
53
+ The ensemble combines their predictions with weights: `0.90 * P_LightGBM + 0.10 * P_XGBoost`.
54
+
55
+ ## Performance Metrics
56
+
57
+ The model demonstrates excellent performance on a holdout test set (7,250 samples):
58
+
59
+ | Metric | Value | Target | Status |
60
+ |---|---|---|---|
61
+ | **PR-AUC** | **0.9437** | ≥ 0.60 | ✓ EXCEEDED |
62
+ | **ROC-AUC** | **0.9528** | ≥ 0.85 | ✓ EXCEEDED |
63
+ | **Recall (Sensitivity)** | **0.8712 (87.1%)** | ≥ 80.0% | ✓ EXCEEDED |
64
+ | **Precision** | **0.9060 (90.6%)** | ≥ 50.0% | ✓ EXCEEDED |
65
+ | **F1-Score** | **0.8883** | ≥ 0.60 | ✓ EXCEEDED |
66
+ | **False Positive Rate** | **4.5%** | ≤ 30.0% | ✓ EXCEEDED |
67
+ | **Optimal Threshold** | **0.3774** | - | - |
68
+
69
+ **Confusion Matrix (Holdout Test Set)**:
70
+
71
+ * **True Negatives (TN)**: 4,633
72
+ * **False Positives (FP)**: 217
73
+ * **False Negatives (FN)**: 309
74
+ * **True Positives (TP)**: 2,091
75
+
76
+ ## Explainability (SHAP)
77
+
78
+ SHAP analysis identified the most influential features for outbreak prediction:
79
+
80
+ 1. **turbidity_roll_std7**: Short-term volatility in water turbidity.
81
+ 2. **turbidity_roll_mean7**: Baseline water cloudiness.
82
+ 3. **turbidity_roc3**: 3-day rate of change in turbidity.
83
+ 4. **turbidity_lag3** & **turbidity_lag1**: Lagged turbidity values.
84
+ 5. **tds_x_turb**: Interaction of total dissolved solids and turbidity.
85
+ 6. **season_cos** & **season_sin**: Cyclical seasonal patterns.
86
+ 7. **reported_cases_roll_std7**: Volatility of active outbreaks.
87
+
88
+ This indicates that rapid increases and high volatility in water turbidity, coupled with seasonal patterns, are strong predictors of outbreaks.
89
+
90
+ ## Usage
91
+
92
+ To use the ArogyaJal Early Warning System for inference, you will need the following artifacts:
93
+
94
+ * `model_lgbm_v2.pkl`
95
+ * `model_xgb_v2.pkl`
96
+ * `ensemble_config.json`
97
+ * `arogyajal_inference.py` (the inference script)
98
+
99
+ ### Example Inference Code
100
+
101
+ ```python
102
+ import pandas as pd
103
+ from arogyajal_inference import OutbreakWarningSystem
104
+
105
+ # Assuming model files and config are in the same directory
106
+ warning_system = OutbreakWarningSystem(
107
+ lgb_path="model_lgbm_v2.pkl",
108
+ xgb_path="model_xgb_v2.pkl",
109
+ config_path="ensemble_config.json"
110
+ )
111
+
112
+ # Prepare new data for prediction (example DataFrame structure)
113
+ df_new = pd.DataFrame({
114
+ 'timestamp': pd.to_datetime(['2024-12-25', '2024-12-26']),
115
+ 'village_id': ['VIL_001', 'VIL_001'],
116
+ 'ph': [7.2, 7.3],
117
+ 'turbidity': [0.8, 1.5],
118
+ 'tds': [32000, 32500],
119
+ 'conductivity': [460, 470],
120
+ 'reported_cases': [0, 1]
121
+ })
122
+
123
+ results = warning_system.predict(df_new)
124
+ alerts = warning_system.get_alerts(results)
125
+
126
+ print("Outbreak Alerts:")
127
+ print(alerts)
128
+ ```
129
+
130
+ ## Installation
131
+
132
+ To run the inference script, you will need the following Python packages:
133
+
134
+ ```bash
135
+ pip install pandas numpy lightgbm xgboost scikit-learn
136
+ ```
137
+
138
+ ## Model Maintenance
139
+
140
+ It is recommended to re-tune the model quarterly using the `arogyajal_train_v2.py` script to adapt to seasonal shifts and maintain optimal performance.