Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,6 +19,7 @@ from analytics.recommendation_logger import (
|
|
| 19 |
build_recommendation_log_rows,
|
| 20 |
build_recommendation_outcome_rows,
|
| 21 |
)
|
|
|
|
| 22 |
from analytics.outcome_grader import build_game_outcome_rows_from_scores
|
| 23 |
from analytics.bankroll import bankroll_curve, grade_profit, summary_metrics
|
| 24 |
from analytics.edge import (
|
|
@@ -80,6 +81,9 @@ from database.db import (
|
|
| 80 |
ensure_game_outcomes_table,
|
| 81 |
insert_game_outcomes,
|
| 82 |
read_game_outcomes,
|
|
|
|
|
|
|
|
|
|
| 83 |
)
|
| 84 |
|
| 85 |
from features.batter_features import batter_summary
|
|
@@ -357,6 +361,7 @@ MAX_LIVE_FEEDS = 6
|
|
| 357 |
ensure_recommendation_logs_table(conn)
|
| 358 |
ensure_recommendation_outcomes_table(conn)
|
| 359 |
ensure_game_outcomes_table(conn)
|
|
|
|
| 360 |
|
| 361 |
@st.cache_data(ttl=SCHEDULE_TTL_SECONDS)
|
| 362 |
def load_wbc_schedule() -> pd.DataFrame:
|
|
@@ -960,6 +965,17 @@ def grade_final_game_outcomes_from_scores(scores_df: pd.DataFrame) -> None:
|
|
| 960 |
except Exception:
|
| 961 |
pass
|
| 962 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 963 |
def render_dashboard() -> None:
|
| 964 |
st.subheader("WBC Live Dashboard")
|
| 965 |
st.caption("Professional scoreboard view")
|
|
@@ -1016,6 +1032,9 @@ def render_dashboard() -> None:
|
|
| 1016 |
if st.button("Grade Final Game Outcomes From Scores", key="grade_final_games_debug"):
|
| 1017 |
grade_final_game_outcomes_from_scores(scores_df)
|
| 1018 |
st.success("Attempted final game grading from scores feed.")
|
|
|
|
|
|
|
|
|
|
| 1019 |
st.write("Current WBC date")
|
| 1020 |
st.write(current_wbc_date_str())
|
| 1021 |
st.write("Scores rows count")
|
|
@@ -1030,6 +1049,16 @@ def render_dashboard() -> None:
|
|
| 1030 |
use_container_width=True,
|
| 1031 |
hide_index=True,
|
| 1032 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1033 |
st.write("Raw score statuses")
|
| 1034 |
st.write(sorted(scores_df["status"].fillna("").astype(str).unique().tolist()))
|
| 1035 |
st.write("Schedule rows")
|
|
|
|
| 19 |
build_recommendation_log_rows,
|
| 20 |
build_recommendation_outcome_rows,
|
| 21 |
)
|
| 22 |
+
from analytics.batter_prop_grader import build_batter_prop_outcome_rows_from_audit
|
| 23 |
from analytics.outcome_grader import build_game_outcome_rows_from_scores
|
| 24 |
from analytics.bankroll import bankroll_curve, grade_profit, summary_metrics
|
| 25 |
from analytics.edge import (
|
|
|
|
| 81 |
ensure_game_outcomes_table,
|
| 82 |
insert_game_outcomes,
|
| 83 |
read_game_outcomes,
|
| 84 |
+
ensure_batter_prop_outcomes_table,
|
| 85 |
+
insert_batter_prop_outcomes,
|
| 86 |
+
read_batter_prop_outcomes,
|
| 87 |
)
|
| 88 |
|
| 89 |
from features.batter_features import batter_summary
|
|
|
|
| 361 |
ensure_recommendation_logs_table(conn)
|
| 362 |
ensure_recommendation_outcomes_table(conn)
|
| 363 |
ensure_game_outcomes_table(conn)
|
| 364 |
+
ensure_batter_prop_outcomes_table(conn)
|
| 365 |
|
| 366 |
@st.cache_data(ttl=SCHEDULE_TTL_SECONDS)
|
| 367 |
def load_wbc_schedule() -> pd.DataFrame:
|
|
|
|
| 965 |
except Exception:
|
| 966 |
pass
|
| 967 |
|
| 968 |
+
def grade_batter_prop_outcomes_from_audit() -> None:
|
| 969 |
+
try:
|
| 970 |
+
audit_df = read_recommendation_audit_view(conn)
|
| 971 |
+
outcome_df = build_batter_prop_outcome_rows_from_audit(
|
| 972 |
+
audit_df=audit_df,
|
| 973 |
+
graded_at=utc_now_iso(),
|
| 974 |
+
)
|
| 975 |
+
insert_batter_prop_outcomes(conn, outcome_df)
|
| 976 |
+
except Exception:
|
| 977 |
+
pass
|
| 978 |
+
|
| 979 |
def render_dashboard() -> None:
|
| 980 |
st.subheader("WBC Live Dashboard")
|
| 981 |
st.caption("Professional scoreboard view")
|
|
|
|
| 1032 |
if st.button("Grade Final Game Outcomes From Scores", key="grade_final_games_debug"):
|
| 1033 |
grade_final_game_outcomes_from_scores(scores_df)
|
| 1034 |
st.success("Attempted final game grading from scores feed.")
|
| 1035 |
+
if st.button("Build Batter Prop Outcome Rows From Audit", key="grade_batter_props_debug"):
|
| 1036 |
+
grade_batter_prop_outcomes_from_audit()
|
| 1037 |
+
st.success("Attempted batter-prop outcome scaffolding from audit rows.")
|
| 1038 |
st.write("Current WBC date")
|
| 1039 |
st.write(current_wbc_date_str())
|
| 1040 |
st.write("Scores rows count")
|
|
|
|
| 1049 |
use_container_width=True,
|
| 1050 |
hide_index=True,
|
| 1051 |
)
|
| 1052 |
+
batter_prop_outcomes_df = read_batter_prop_outcomes(conn)
|
| 1053 |
+
st.write("Batter prop outcome rows")
|
| 1054 |
+
st.write(len(batter_prop_outcomes_df))
|
| 1055 |
+
|
| 1056 |
+
if not batter_prop_outcomes_df.empty:
|
| 1057 |
+
st.dataframe(
|
| 1058 |
+
batter_prop_outcomes_df.tail(20),
|
| 1059 |
+
use_container_width=True,
|
| 1060 |
+
hide_index=True,
|
| 1061 |
+
)
|
| 1062 |
st.write("Raw score statuses")
|
| 1063 |
st.write(sorted(scores_df["status"].fillna("").astype(str).unique().tolist()))
|
| 1064 |
st.write("Schedule rows")
|