- 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).
56 lines
1.4 KiB
Python
56 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
|
|
def test_healthz(client):
|
|
response = client.get("/healthz")
|
|
assert response.status_code == 200
|
|
assert response.json() == {"ok": True}
|
|
|
|
|
|
def test_readyz(client):
|
|
response = client.get("/readyz")
|
|
assert response.status_code == 200
|
|
assert response.json() == {"ok": True, "model": True}
|
|
|
|
|
|
def test_meta_contract(client):
|
|
response = client.get("/meta")
|
|
assert response.status_code == 200
|
|
payload = response.json()
|
|
|
|
for key in (
|
|
"data_version",
|
|
"model_version",
|
|
"context_version",
|
|
"coverage",
|
|
"metrics",
|
|
"trained_at",
|
|
"train_from",
|
|
"train_to",
|
|
"features",
|
|
"holiday_effect",
|
|
):
|
|
assert key in payload, key
|
|
|
|
assert payload["coverage"]["sensors"] == 8
|
|
assert payload["coverage"]["cadence_min"] == 15
|
|
assert payload["coverage"]["from"].endswith("Z")
|
|
|
|
headline = payload["metrics"]
|
|
assert headline["mae"] < headline["baseline_mae"]
|
|
assert headline["wape"] < headline["baseline_wape"]
|
|
assert headline["r2"] > headline["baseline_r2"]
|
|
assert 0 < headline["wape"] < 100
|
|
assert 0.5 < headline["r2"] <= 1.0
|
|
|
|
assert "small_model" in payload
|
|
assert payload["small_model"]["features"] == [
|
|
"hour",
|
|
"weekday",
|
|
"is_weekend",
|
|
"temp_c",
|
|
"precip_mm",
|
|
"is_holiday",
|
|
]
|
|
assert 0.5 < payload["small_model"]["metrics"]["accuracy"] <= 1.0
|