Syntrex commited on
Commit
154aa0b
·
verified ·
1 Parent(s): e01d7ed

Update analytics/recommendation_engine.py

Browse files
Files changed (1) hide show
  1. analytics/recommendation_engine.py +14 -7
analytics/recommendation_engine.py CHANGED
@@ -1,7 +1,5 @@
1
  from __future__ import annotations
2
 
3
- from typing import Any
4
-
5
  import pandas as pd
6
 
7
  from analytics.confidence import compute_confidence
@@ -10,13 +8,13 @@ from models.live_fair_simulator_v3 import build_upcoming_simulated_rows
10
 
11
 
12
  def build_upcoming_hitter_recommendations(
13
- game_row: dict[str, Any],
14
  statcast_df: pd.DataFrame,
15
  odds_df: pd.DataFrame | None = None,
16
- weather_row: dict[str, Any] | None = None,
17
- ) -> list[dict[str, Any]]:
18
  """
19
- Batch 3 decision-layer wrapper.
20
  Uses simulated fair rows, then adds confidence + recommendation tier.
21
  """
22
  rows = build_upcoming_simulated_rows(
@@ -25,7 +23,7 @@ def build_upcoming_hitter_recommendations(
25
  weather_row=weather_row,
26
  )
27
 
28
- recommendations: list[dict[str, Any]] = []
29
 
30
  for row in rows:
31
  confidence_block = compute_confidence(row, game_row=game_row)
@@ -36,4 +34,13 @@ def build_upcoming_hitter_recommendations(
36
 
37
  recommendations.append(row)
38
 
 
 
 
 
 
 
 
 
 
39
  return recommendations
 
1
  from __future__ import annotations
2
 
 
 
3
  import pandas as pd
4
 
5
  from analytics.confidence import compute_confidence
 
8
 
9
 
10
  def build_upcoming_hitter_recommendations(
11
+ game_row: dict,
12
  statcast_df: pd.DataFrame,
13
  odds_df: pd.DataFrame | None = None,
14
+ weather_row: dict | None = None,
15
+ ) -> list[dict]:
16
  """
17
+ Decision-layer wrapper.
18
  Uses simulated fair rows, then adds confidence + recommendation tier.
19
  """
20
  rows = build_upcoming_simulated_rows(
 
23
  weather_row=weather_row,
24
  )
25
 
26
+ recommendations: list[dict] = []
27
 
28
  for row in rows:
29
  confidence_block = compute_confidence(row, game_row=game_row)
 
34
 
35
  recommendations.append(row)
36
 
37
+ recommendations = sorted(
38
+ recommendations,
39
+ key=lambda x: (
40
+ float(x.get("priority_score", 0.0) or 0.0),
41
+ float(x.get("confidence", 0.0) or 0.0),
42
+ ),
43
+ reverse=True,
44
+ )
45
+
46
  return recommendations