feat: complete ML pipeline, FastAPI service, small model, tests, image

- finish the global HistGB bundle, scenario forecasts and 28-day ablation
- export sensors/series/forecasts/metrics/context plus baked weather frames
- add FastAPI health/meta/predict/simulate and background /train jobs
- add the p75 busy classifier, retraining from CSV, and hot-swap persistence
- add pytest coverage, multi-stage non-root Dockerfile, README and model card

Holdout: weather 7d MAE 3.32 / WAPE 27.5% / R2 0.777 vs seasonal naive
MAE 4.23 / WAPE 35.0% / R2 0.656 (5,350 eval rows).
This commit is contained in:
Noel Sabia committed 2026-11-14 05:01:16 +01:00
1 parent 68402803b2
commit 939a8db482
43 files changed
+4090 -105

No files matched your search

+6 -4
View File
@@ -78,8 +78,10 @@ def clean(df: pd.DataFrame) -> tuple[pd.DataFrame, pd.DataFrame, dict]:
)
multi = density[density["time"] >= pd.Timestamp(config.MULTI_SENSOR_START)]
# The device merge spans the full history: the old device is outside the
# 8-sensor window, so counting only `multi` would hide it.
density_01_devices = (
multi[multi["sensor"] == "density-01"]
density[density["sensor"] == "density-01"]
.groupby("sensor_id", observed=True)
.agg(rows=("value", "size"), first=("time", "min"), last=("time", "max"))
)
@@ -99,9 +101,9 @@ def clean(df: pd.DataFrame) -> tuple[pd.DataFrame, pd.DataFrame, dict]:
)
audit = {
"raw_rows": int(len(df)),
"density_rows": int(len(df[df["type"] == "densityData"])),
"battery_rows": int(len(df[df["type"] == "batteryData"])),
"raw_rows": len(df),
"density_rows": len(df[df["type"] == "densityData"]),
"battery_rows": len(df[df["type"] == "batteryData"]),
"device_ids": int(df["sensor_id"].nunique()),
"sensor_names": int(df["name"].nunique()),
"usable_sensors": len(usable),