feat: Sprint 2 - 概率语义 + 轻量快照 + 数据库约束

P0-05: confidence → subjective_confidence 改名(15 文件)
       LLM 主观置信度与概率分离
P0-02: predictions 增加 cutoff_at + input_hash(轻量快照)
       MatchContext 暴露 match_dt
       单/多 Agent 路径均记录快照元数据
P2-05: 数据库 CHECK 约束
       - pred_home_goals >= 0
       - pred_away_goals >= 0
       - subjective_confidence 0~1
       - pred_1x2 IN (1,X,2)
       - mode IN (single,multi)
P2-06: limit 分页约束(ge=1, le=200)
P2-01: 新增 /health/ready 就绪检查
This commit is contained in:
shangfangjian
2026-09-15 00:14:24 +08:00
parent f3160e3062
commit cb36dc3ef9
14 changed files with 70 additions and 41 deletions
+4 -4
View File
@@ -139,7 +139,7 @@ async def run_backtest(
pred_home=result.pred_home_goals,
pred_away=result.pred_away_goals,
pred_1x2=result.pred_1x2,
confidence=result.confidence,
subjective_confidence=result.subjective_confidence,
correct_1x2=correct,
prediction_id=result.prediction_id,
)
@@ -164,7 +164,7 @@ async def run_backtest(
summary.avg_score_rmse = round(sum(errors) / len(errors), 2)
# 平均置信度
confs = [r.confidence for r in summary.results if r.confidence is not None]
confs = [r.subjective_confidence for r in summary.results if r.subjective_confidence is not None]
if confs:
summary.avg_confidence = round(sum(confs) / len(confs), 2)
@@ -184,11 +184,11 @@ def _compute_calibration(results: list[BacktestMatchResult]) -> list[dict]:
"0.0-0.3": {"range": (0.0, 0.3), "total": 0, "correct": 0},
}
for r in results:
if r.confidence is None:
if r.subjective_confidence is None:
continue
for key, b in buckets.items():
lo, hi = b["range"]
if lo <= r.confidence <= hi:
if lo <= r.subjective_confidence <= hi:
b["total"] += 1
if r.correct_1x2:
b["correct"] += 1