fix(ai-engine): hoist ms_edge before score prediction branch to prevent UnboundLocalError
Deploy Iddaai Backend / build-and-deploy (push) Successful in 5s

This commit is contained in:
2026-05-05 20:34:14 +03:00
parent fdb8a5d0f0
commit 4bc51cfa99
@@ -925,6 +925,7 @@ class SingleMatchOrchestrator:
prediction.handicap_confidence = hcap_top * 100.0
# ── Score Prediction: Model-first, heuristic fallback ──────────
ms_edge = prediction.ms_home_prob - prediction.ms_away_prob
score_result = self._predict_score_with_model(features)
if score_result is not None:
# ML model predicted scores
@@ -939,7 +940,7 @@ class SingleMatchOrchestrator:
# Heuristic fallback (original formula)
base_home_xg = max(0.25, (float(data.home_goals_avg) + float(features.get("away_xga", data.away_conceded_avg))) / 2.0)
base_away_xg = max(0.25, (float(data.away_goals_avg) + float(features.get("home_xga", data.home_conceded_avg))) / 2.0)
ms_edge = prediction.ms_home_prob - prediction.ms_away_prob
# ms_edge already computed above
total_target = max(
1.4,
min(