Spaces:
Sleeping
Sleeping
Commit History
-
Merge remote: resolve mlb_starters.py conflict — keep conn param + remote team canonical map
Remote added _MLB_TEAM_CANONICAL, _canonical_team, _normalize_person, _names_match, build_oddsapi_starter_fallback_map, merge_probable_starters_with_odds_fallback, fetch_mlb_current_roster_map, and lookup_batter_current_team. Combined with our conn=None parameter and pitcher_resolution_log logging additions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>abe5c7e -
Accuracy overhaul: pitcher resolution logging, baseline recalibration, vig fix, XGBoost blend
Phase 1: Unified pitcher name normalization (normalize_pitcher_name), added pitcher_resolution_log table with logging from mlb_starters, live feed, and statcast lookup. Color-coded debug page section for resolution audit. Phase 2: Baseline HR probability 0.045 → 0.036 (empirical MLB 2024 per-PA rate). Phase 3: HR edge now uses single-sided vig removal (p / 1.055) instead of circular two-way normalization. Added kelly_pct to recommendation output. Phase 4: Removed double-counted temperature/wind adjustments from context_adjustment.py — environment_model.py owns all weather signals. Phase 5: BET threshold 6%/78 → 3.5%/72; WATCH 2.5%/62 → 1.5%/58. Phase 6: XGBoost HR delta blended at 20% weight when xgb_blend_eligible. Added validate_xgb_batch() for batch-level sanity checks. Phase 7: Hit-type distribution corrected — singles 0.76→0.62, doubles 0.20→0.33 (empirical MLB 2024 non-HR hit mix). Phase 9: edge.py converted to re-exports from no_vig_props.py (single source of truth for al…21151ce
-
Fix pitcher resolution: add MLB roster fallback for batter team lookup
Root cause: _resolve_batter_team() used historical statcast (2025 season) to identify a batter's team. Players who changed teams in the offseason had stale team names that no longer matched either participant in today's game, causing `batter_team_unresolved` and leaving pitchers unresolved even when both starters were known. Changes: - props_mapper.py: restructure _resolve_batter_team() so statcast early- exits no longer skip the roster fallback; suppress stale historical-team returns that don't match the current game (removed old line 349) - mlb_starters.py: add fetch_mlb_current_roster_map() (MLB Stats API /api/v1/sports/1/players?season=2026, process-lifetime cached) and lookup_batter_current_team() which is called as Level 4 fallback in _resolve_batter_team() when statcast resolution fails Players now resolve via "mlb_roster_lookup" source for offseason acquisitions, new players, and anyone not in statcast data. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>f2d8d50 -
Remove Fangraphs from Props runtime
c4cd7c6 -
Add safe FanGraphs starter fallback
51b1a14 -
Stabilize props baseline and starter resolution
bb05a74 -
Hide tracked-only games from HR game explorer
7ac6efd -
Improve app speed via payload caching and reuse
54a42dd -
Optimize props load path and reuse modeled state
2885bcc
-
Promote strikeout v2 and harden telemetry models
50dc123 -
Add props confidence breakdown diagnostics
d3b6f35 -
Add slate-wide props best-value coverage
090e487 -
Improve props edge reliability diagnostics
0c51058
-
Add shared multi-year baseline service
7b3d14f -
Personalize props model voice
4c8e6d6 -
Expand props with verdicts strikeouts and loader
6989587 -
Upgrade props HR calibration and Fangraphs fallback
0010624 -
Redesign HR props command center
49fb892 -
Fix props pregame HR routing and odds provider fallback
87523c1 -
Add shared pregame HR engine for Props
9246aa7 -
Fix HR% blank for Jr./Sr. players: add suffix-stripped name index key
Sportsbooks sometimes omit suffixes (Jr., Sr., II) that Baseball Savant always includes. _build_statcast_name_index() now adds a 3rd key per player using normalize_for_matching() from the card lab — strips suffixes, hyphens, apostrophes — so "Vladimir Guerrero" resolves to the same statcast row as "Guerrero Jr., Vladimir". Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>5aa0880 -
Fix Model HR% blank: name format mismatch + column renames
Root causes: 1. Baseball Savant uses "Last, First" names; sportsbooks use "First Last". _build_statcast_name_index() now uses to_canonical_name() (from card lab) to index both forms — fixes 100% player lookup failure. 2. normalize_statcast() renames estimated_woba_using_speedangle → xwoba and stand → batter_stand. batter_baseline.py still used original names → xwoba always None, batter_stand always defaulted to "R". Fixed both lookups. 3. normalize_statcast() silently dropped spray_angle, hc_x, hc_y, bb_type. Added to rename_map so pull_rate, air_ball_rate, bb_type shape metrics are available to compute_batter_baseline(). 4. Added WARNING log after statcast load showing row count + sample names to confirm load success and name format in HuggingFace Spaces logs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>70995df -
Props: multi-book concat-all, full pre-game model stack, pre-season statcast fallback
Issue A: Switch fetch_all_upcoming_hr_props from stop-at-first to concat-all so Odds API partial data (e.g. Caesars only) no longer blocks the scraper. Dedup by best odds per (player_name, sportsbook_key, market) after merge. Issue B: Fall back to load_statcast_previous_season_full() (2025) when load_statcast_recent() returns empty (pre-season). Model HR% now populates. Issue C: Full pre-game model stack in props_mapper._get_full_pregame_adjustments(): - Pitcher quality ±0.025 via compute_pitcher_adjustment() [dominant signal] - Zone matchup ±0.010 via batter_zone_store + pitcher_zone_model - Arsenal matchup ±0.010 via batter/pitcher arsenal feature rows - Rolling form ±0.012 via compute_upcoming_rolling_adjustment() - Park factor ±0.006 via HOME_TEAM_TO_STADIUM + compute_park_adjustment() New data sources: - data/mlb_starters.py: probable starters from MLB Stats API, cached 1h - data/statcast.py: fetch_statcast_range_pitcher() for pitcher-perspective data - app.py: …37fe240
-
Fix batter_prop_outcomes explosion: dedup audit view + scoped grading
Root cause: read_recommendation_audit_view produced Cartesian-product rows (source tables written every 3s × no dedup in JOIN), and Step 3 appended the full inflated history on every game completion with no game_pk filter and no conflict guard. Fixes applied: - read_recommendation_audit_view: DISTINCT ON CTEs on both sides of the JOIN before joining; latest_outcomes scoped to market='hr' to prevent future market-multiplication - Step 3: filter audit_df to current game_pk; scoped delete before insert (idempotent per game) - Step 4: read/delete/insert scoped to current game_pk only (stops full-table churn) - build_batter_prop_outcome_rows_from_audit: dedup on (game_pk, batter_name, market) before returning - Manual debug button: replace instead of insert (idempotent) - ensure_batter_prop_outcomes_table: CREATE UNIQUE INDEX on (game_pk, batter_name, market) as hard backstop post-rebuild - New helpers: delete_batter_prop_outcomes_for_game, read_batter_prop_outcomes_for_game …22080c8
-
Fix QueuePool exhaustion: combine live pitch+PA upsert into single connection
Replace 2 separate get_connection() calls per live game inside @st.cache_data with a single combined upsert fired in a background daemon thread. Halves peak pool usage (2 sessions × 5 games: 20→10 connections), preventing TimeoutError at module-level conn acquisition. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>b70ab2f -
Live pitch ingestion into live_pitch_mix_2026 + overlap diagnostics fix
Part A: debug_page.py — overlap diagnostics now builds EXISTS clauses only for tables that actually exist, preventing UndefinedTable errors; corrects live_pa_events_2026 → live_batter_game_log_2026 throughout. Part B: analytics/game_completion.py — adds _upsert_df_backfill (DO UPDATE COALESCE) for post-game Savant backfill into live-ingested rows; adds public upsert_live_pitch_rows / upsert_live_pa_log_rows helpers. app.py — hooks prepare_live_game_for_ui() to populate live_pitch_mix_2026 and live_batter_game_log_2026 pitch-by-pitch during games via allPlays feed; zone=None pending integer classifier (per safety rule). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>0780ec2 -
Add live 2026 pitch/PA tables and migrate Card Lab to new sources
New tables live_pitch_mix_2026 (pitch-level) and live_batter_game_log_2026 (PA-level) are created in db.py and wired into the post-game ingestion pipeline in game_completion.py. Card Lab queries are year-gated: 2026 hitter/pitcher cards and all Game Summary cards now read from the new live tables (no 3-table JOIN), while 2021-2025 cards continue using statcast_event_core. Game Summary hitter rows are now sourced from live_batter_game_log_2026 (one row per PA, real batter identity via MLBAM ID) instead of grouping pitch-level data by pitcher name. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>9846940 -
Debug tab: fix caption disappears via st.toggle (no session_state write)
Replace st.button + manual session_state with st.toggle so the sidebar radio no longer resets to Dashboard on click. Also includes game-completion pipeline (on_game_complete, statcast retry fragment) and statcast core schema initialization. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>d8c9977
-
Tier 5A execution layer + Alpha Release tab + edge strip fix
- analytics/execution_layer.py: New post-model enrichment pass (5 sequential tasks: market disagreement, edge quality, timing, correlation, final score) - analytics/props_mapper.py: Wire enrich_with_execution_layer at end of map_hr_props_to_model; try/except with logger.warning fallback - analytics/recommendation_engine.py: Add prop_odds_df param; inject real live HR prop odds per batter (MAX odds_american, normalized + raw name fallback, book_hr_odds_source field); logs mapping misses - data/live_prop_odds.py: Fix silent exception in fetch_live_prop_odds - app.py: load_hr_prop_odds_for_game (60s TTL) wired into dashboard; replace render_algorithm_breakdown with render_alpha_release (10 expanders, disclaimer, no WBC content); rename nav entry - visualization/props_page.py: Store mapped df in session_state; Execution Layer expander after HR props table - visualization/debug_page.py: Section 5c Execution Layer reading from session_state - visualization/recommendation_pane…dba351a -
Audit-confirmed fixes: matchup confidence blend + platoon unknown handling
- zone_matchup_model + matchup_model: sample_size now populated so confidence_blend branch is reachable (was always max_fallback before) - live_fair_simulator_v3: batter_stand/p_throws default to None → unknown rows get multiplier 1.0 instead of false 0.92 suppression - Supporting changes: props mapper, recommendation engine, schedule, scores, bullpen model, pitcher adjustment/state, rolling form, zone matchup, debug page, logger utility Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>95e27f5
-
Batch 14: HR props odds-injection layer + Props page
- Add fetch_all_upcoming_hr_props() bulk fetch (single API call, no game filter) - Add Caesars (williamhill_us) to provider supported books; document Pinnacle path - Add analytics/props_mapper.py: get_player_hr_prob() with source tracking (internal_model_baseline via compute_batter_baseline, fallback to unavailable); modular map_hr_props_to_model() with injectable prob_fn - Add upcoming_hr_props table to durable DuckDB schema - Add visualization/props_page.py: Props page with all-book + best-line views, sportsbook filter, min-edge slider, edge-sorted table, DB logging - Replace Players tab with Props tab in app navigation Deferred: Batch 13, Batch 12.5 follow-up, Pinnacle integration, CLV, bankroll sizing Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>2099da5 -
Batch 12.5D: XGBoost shadow model + evaluation pipeline + lineup_slot JOIN fix
- Add XGBoost HR/hit/TB2P models (trainer, dataset builder, shadow integration) - Add evaluation pipeline with 3-key JOIN (game_pk + batter_name + lineup_slot) - Fix lineup_slot schema in both DB tables with safe migration - Normalize lineup_slot in both logger paths for consistent JOIN - Add placeholder-odds disclaimer to Edge/ROI evaluation output - Add .gitignore excluding .claude/ and __pycache__ Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>71c16c1
-
Update analytics/recommendation_engine.py
Verified signature247bd3d -
Update analytics/recommendation_engine.py
Verified signature26e7378 -
Update analytics/recommendation_engine.py
Verified signature684b4f0
-
Update analytics/recommendation_engine.py
Verified signatureb761d20 -
Update analytics/recommendation_engine.py
Verified signature67f928e -
Update analytics/recommendation_engine.py
Verified signature424a63c -
Update analytics/recommendation_engine.py
Verified signaturec8d7762 -
Update analytics/recommendation_engine.py
Verified signature9f10209 -
Update analytics/recommendation_engine.py
Verified signaturee2bfd69
-
Update analytics/evaluation_metrics.py
Verified signatureac935c3 -
Update analytics/evaluation_metrics.py
Verified signatureb0c70fb
-
Create batter_audit_metrics.py
Verified signature7846bd6
-
Create batter_realization.py
Verified signatureabeeae7 -
Create batter_prop_grader.py
Verified signature11a48b1 -
Create outcome_grader.py
Verified signaturebd8f997 -
Update analytics/evaluation_metrics.py
Verified signature51394db -
Create evaluation_metrics.py
Verified signature1e0a583 -
Update analytics/recommendation_logger.py
Verified signature5ff23fe