Add DEB city trust tiers
This commit is contained in:
@@ -39,6 +39,56 @@ def test_training_accuracy_payload_includes_recent_deb_summary():
|
||||
assert "deb_v2_bucket_calibrated" in payload["deb_summary"]["versions"]
|
||||
|
||||
|
||||
def test_training_accuracy_payload_includes_city_deb_trust_strategy():
|
||||
history = {
|
||||
"alpha": {
|
||||
"2026-06-01": {"actual_high": 20.0, "deb_prediction": 20.1},
|
||||
"2026-06-02": {"actual_high": 21.0, "deb_prediction": 21.1},
|
||||
"2026-06-03": {"actual_high": 22.0, "deb_prediction": 22.2},
|
||||
"2026-06-04": {"actual_high": 23.0, "deb_prediction": 23.0},
|
||||
"2026-06-05": {"actual_high": 24.0, "deb_prediction": 24.1},
|
||||
},
|
||||
"beta": {
|
||||
"2026-06-01": {"actual_high": 30.0, "deb_prediction": 28.0},
|
||||
"2026-06-02": {"actual_high": 31.0, "deb_prediction": 29.0},
|
||||
"2026-06-03": {"actual_high": 32.0, "deb_prediction": 30.0},
|
||||
"2026-06-04": {"actual_high": 33.0, "deb_prediction": 31.0},
|
||||
"2026-06-05": {"actual_high": 34.0, "deb_prediction": 32.0},
|
||||
},
|
||||
"gamma": {
|
||||
"2026-06-05": {"actual_high": 25.0, "deb_prediction": 25.1},
|
||||
},
|
||||
}
|
||||
registry = {
|
||||
"alpha": {"name": "Alpha"},
|
||||
"beta": {"name": "Beta"},
|
||||
"gamma": {"name": "Gamma"},
|
||||
}
|
||||
|
||||
payload = _build_training_accuracy_payload(
|
||||
history,
|
||||
registry,
|
||||
today_str="2026-06-07",
|
||||
)
|
||||
|
||||
rows = {row["city_id"]: row for row in payload["accuracy"]}
|
||||
|
||||
assert rows["alpha"]["deb_recent"]["recent_7d"]["samples"] == 5
|
||||
assert rows["alpha"]["deb_recent"]["recent_7d"]["hit_rate"] == 100.0
|
||||
assert rows["alpha"]["deb_recent"]["trust_tier"] == "high"
|
||||
assert rows["alpha"]["deb_recent"]["recommendation"] == "primary"
|
||||
assert rows["alpha"]["deb_recent"]["bias_direction"] == "neutral"
|
||||
|
||||
assert rows["beta"]["deb_recent"]["recent_14d"]["samples"] == 5
|
||||
assert rows["beta"]["deb_recent"]["trust_tier"] == "low"
|
||||
assert rows["beta"]["deb_recent"]["recommendation"] == "context_only"
|
||||
assert rows["beta"]["deb_recent"]["bias_direction"] == "under"
|
||||
assert "recent_14d" in rows["beta"]["deb_recent"]["reason"]
|
||||
|
||||
assert rows["gamma"]["deb_recent"]["trust_tier"] == "insufficient"
|
||||
assert rows["gamma"]["deb_recent"]["recommendation"] == "insufficient"
|
||||
|
||||
|
||||
def test_training_accuracy_payload_caps_version_backtest_samples(monkeypatch):
|
||||
start = date(2025, 1, 1)
|
||||
history = {
|
||||
|
||||
Reference in New Issue
Block a user