Spaces:
Running
Running
Aadithya commited on
Commit ·
08f8258
1
Parent(s): 39cb936
feat: implement mean-matching ensemble to calibrate chronos output against sarima baseline
Browse files- worker/tasks.py +17 -0
worker/tasks.py
CHANGED
|
@@ -71,6 +71,23 @@ def run_gridops_pipeline(self, dataset_path: str, severity_threshold: float = 0.
|
|
| 71 |
chronos_p50 = chronos_result['p50']
|
| 72 |
chronos_p90 = chronos_result['p90']
|
| 73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
assert not isinstance(chronos_p10, list)
|
| 75 |
assert not isinstance(chronos_p50, list)
|
| 76 |
assert not isinstance(chronos_p90, list)
|
|
|
|
| 71 |
chronos_p50 = chronos_result['p50']
|
| 72 |
chronos_p90 = chronos_result['p90']
|
| 73 |
|
| 74 |
+
import numpy as np
|
| 75 |
+
|
| 76 |
+
# --- Mean-Matching Ensemble Calibration ---
|
| 77 |
+
# SARIMA (16-yr context) provides the structurally accurate baseline mean
|
| 78 |
+
sarima_mean = np.mean(sarima_fc)
|
| 79 |
+
|
| 80 |
+
# Chronos provides the high-fidelity shape, but has a recency-biased mean
|
| 81 |
+
chronos_mean = np.mean(chronos_p50)
|
| 82 |
+
|
| 83 |
+
# Calculate the bias shift required to anchor Chronos to SARIMA
|
| 84 |
+
bias_shift = sarima_mean - chronos_mean
|
| 85 |
+
|
| 86 |
+
# Apply the shift and mathematically clip to 0 to prevent negative physical loads
|
| 87 |
+
chronos_p10 = np.maximum(chronos_p10 + bias_shift, 0.0)
|
| 88 |
+
chronos_p50 = np.maximum(chronos_p50 + bias_shift, 0.0)
|
| 89 |
+
chronos_p90 = np.maximum(chronos_p90 + bias_shift, 0.0)
|
| 90 |
+
|
| 91 |
assert not isinstance(chronos_p10, list)
|
| 92 |
assert not isinstance(chronos_p50, list)
|
| 93 |
assert not isinstance(chronos_p90, list)
|