Spaces:
Sleeping
Sleeping
Commit History
-
Odds tab: add pitcher strikeout alt lines with Standard/Alt Lines/Both view toggle
- Fetch pitcher_strikeouts_alternate market from TheOddsAPI - Normalize alt K rows: populate threshold from line, set market_variant=alternate, is_primary_line=False - Fix latent bug: threshold now populated for all K rows, enabling Strikeout Ladder Summary to render - Ladder Summary gains Variant column (Standard/Alt/Mixed), sorted Standard-first - K section adds horizontal radio: Standard (existing O/U grids) | Alt Lines (Over-only alt grid) | Both (unified single table of all lines) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>17be445
-
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 roster cache hammering: rate-limit empty/error retries to 5 minutes
The previous fix (don't cache empty roster results) caused the debug page to hammer the MLB Stats API — one HTTP request per pitcher candidate (~30 total) per page render, each with a 15s timeout, blocking for 7+ minutes and causing HuggingFace to kill and restart the container. Add _ROSTER_MAP_EMPTY_UNTIL timestamp: on empty result or network error, block retries for 5 minutes. This allows recovery without hammering the API, while still eventually retrying (unlike the original permanent-cache bug). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>fd52637 -
Fix pitcher resolution table: roster cache, two-candidate fallback, debug rebuild
RC1: fetch_mlb_current_roster_map() now uses gameType="R,S" so spring training roster data is returned pre-opening-day. Empty results (network error or truly empty API response) no longer permanently cache {} — the guard now returns {} without setting _ROSTER_MAP_CACHE, so the next call retries. RC2: Debug page pitcher resolution expander now always rebuilds from the live props feed (upcoming_props_debug) rather than only when session state is empty. Previously, visiting Props page first would populate merged_starters with Stats-API-only data, making `if not merged_starters` False and skipping odds API pitchers entirely. RC3: build_oddsapi_starter_fallback_map() adds elif branch for the two-candidate both-blank scenario: when exactly 2 K-props pitcher candidates exist, team inference fails for both, and neither away nor home pitcher has been set, assign alphabetically as a deterministic last-resort heuristic. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>a54e483 -
Feed odds API pitchers into debug pitcher resolution table
- In build_oddsapi_starter_fallback_map(): after _infer_pitcher_team_from_rows() returns empty, fall back to lookup_batter_current_team() (roster API cache) so offseason acquisitions/traded pitchers are correctly team-matched - In render_debug(): when session state has no props_prepared_bundle, build the pitcher resolution table directly from upcoming_props_debug merged_props_feed + DB-cached probable starters, eliminating the requirement to visit the Props page first in the same session - Add read_cached_probable_starters, build_oddsapi_starter_fallback_map, merge_probable_starters_with_odds_fallback imports to debug_page.py Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>c16be6b
-
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 -
Perf: parallelize TheOddsAPI event loop, fix schema init overhead
- provider_theoddsapi: replace serial per-event HTTP loop (worst case 457s) with ThreadPoolExecutor(max_workers=8) + 45s wall-clock cap via concurrent.futures.wait; adds _fetch_event_odds() helper - database/db: initialize_schema() now runs once per process lifetime via _schema_initialized guard + lock instead of on every get_connection() - shared_baseline: wrap 8 sequential snapshot DB reads in a daemon thread with 20s wall-clock timeout; returns degraded bundle on timeout - app.py: wrap replace_cached_upcoming_props_bundle() write in a daemon thread with 15s timeout so cache persist never blocks the render path Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>bd7830d -
Hotfix: add missing logging import and _log definition to shared_baseline.py
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>d62515b -
Fix props page hang: reduce build timeout to 5s, fix st.session_state in cache, async log
- Reduce _FALLBACK_BUILD_TIMEOUT_SECONDS from 40s to 5s: users now wait max 5s before content appears (vs 40s which appeared as a hang) - Move st.session_state write out of @st.cache_data to render_props(): prevents StreamlitAPIException on newer Streamlit; use setdefault to avoid resetting the reload timer on reruns - Wrap _maybe_log_props() in threading.Thread with join(timeout=5): prevents DB insert hang from blocking the render pipeline; logs still written synchronously within 5s or fire-and-forget if DB is slow Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>28a1d5a -
Add 40s timeout to baseline build branches to prevent props page hang
Wraps Branch 2 (patch build) and Branch 3 (full fallback build) in threading.Thread with join(timeout=40). On timeout: returns empty/partial bundle immediately, queues a persist-when-done background thread so next load hits the fast snapshot path. Props page shows an info banner and auto-reloads ~80s later once snapshots are populated. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>7b21bf1 -
Fix pitcher resolution via canonical team mapping; remove live edge strip UI
- data/mlb_starters.py: Add _MLB_TEAM_CANONICAL dict and _canonical_team() to bridge statcast abbreviations (sfg) against Odds API full names (san francisco giants). Update _infer_pitcher_team_from_rows() and lookup_pitchers_for_game() to use canonical comparison. - app.py: Remove render_recommendation_panels() and render_model_explainer() calls from render_live_games_with_edge_strips() — DB logging logic intact. - visualization/debug_page.py: Add Pitcher Resolution expander showing merged_starters per matchup with sources. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>dd66ccf -
Remove Fangraphs from Props runtime
c4cd7c6 -
Remove Fangraphs starter fallback in favor of MLB and Odds API
0dfe795 -
Add safe FanGraphs starter fallback
51b1a14 -
Recover props/debug load times
549ba63 -
Stabilize props baseline and starter resolution
bb05a74
-
Add DraftKings-first HR supplemental coverage
7e836ba -
Complete multi-book HR source coverage
5591dd3 -
Improve multi-book props coverage reconciliation
66db1db -
Make debug snapshot reads retry-safe
a937adb -
Fix props baseline snapshot name resolution
e8b0f2e -
Scope props baseline loading by market
b1e5e19 -
Optimize serving path with row-based snapshots
88f040e -
Improve load-time caching and baseline snapshots
c4ae8c3
-
Add shared multi-year baseline service
7b3d14f -
Expand props with verdicts strikeouts and loader
6989587 -
Upgrade props HR calibration and Fangraphs fallback
0010624 -
Redesign HR props command center
49fb892 -
Add Caesars to default player prop books
0fb83f4 -
Add odds API coverage probe diagnostics
e213a9c -
Fix upcoming HR odds request books
3f1dfee -
Fix upcoming odds API sportsbook scope
f75a6ed -
Hotfix upcoming odds provider and debug visibility
4c9ab29 -
Fix props pregame HR routing and odds provider fallback
87523c1 -
Fix statcast: fetch regular season data, increase timeout
hfGT was set to "F|D|L|W|" (postseason only), so only players from 2025 playoff teams had statcast rows — all others returned "unavailable". Changed to "R|" (regular season) to fetch the full player pool. Increased timeout from 60s to 180s to handle the larger full-season response (~700k rows vs ~10k postseason). Cache TTL of 12h means the slow initial fetch only happens once. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>c5f09df -
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
-
Add multi-book scrape fallback for HR props + restore Odds API market key
The Odds API indexes h2h first, player props later (24-48h before game time). FanDuel/DK have props posted but Odds API hasn't crawled them yet. Changes: - provider_theoddsapi.py: restore markets=batter_home_runs (correct key), remove DIAGNOSTIC block (served its purpose) - provider_scrape.py (new): ScrapeFallbackProvider with independent fetchers for DraftKings, FanDuel, BetMGM, and Caesars using their semi-public JSON APIs. Each book's failure is caught independently. DraftKings uses dynamic category discovery (survives ID changes). - live_prop_odds.py: change from concat-all to stop-at-first-success chaining. Register ScrapeFallbackProvider after TheOddsAPIProvider. Scraper only runs when Odds API returns empty. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>0ff601a -
Broaden per-event call: remove markets+bookmakers filters, filter client-side
books=[] for all 15 events despite FanDuel having HR props posted. API subscription is paid/full. Narrowing with markets=batter_home_runs and bookmakers=dk,fd,betmgm is silently returning empty results. Changes: - Remove books variable construction and early guard - Drop markets and bookmakers from odds_params (keep regions=us only) - Client-side market filter (market_key != batter_home_runs) unchanged - Add DIAGNOSTIC WARNING for first event showing books_returned and markets_available so we can see the actual market keys in the response Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>5a49085 -
Promote per-event structure and counter logs from info→warning
With total_rows=0 but all 200s, the parsing loop is silently discarding all data. The structure log (books=, markets=, outcome_counts=) and counter log (bookmakers=N outcomes=N skip_name=N etc.) were at info level — invisible in HuggingFace Spaces. Now promoted to warning so we can see exactly where rows are being dropped for each of 15 events. Zero logic changes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>f3ee3fd -
Promote 5 diagnostic logs from info→warning in fetch_all_upcoming_hr_props
HuggingFace Spaces only surfaces WARNING+ logs; all info() calls were invisible. Changes (zero logic changes): 1. Add warning on ODDS_API_KEY empty early return (was fully silent) 2. events HTTP status → _diag_log.warning 3. events found count → _diag_log.warning 4. Step2 per-event HTTP status → _diag_log.warning 5. SUMMARY line → _diag_log.warning After this push, Spaces log will always show events found count, per-event HTTP status, and final SUMMARY (total_rows=N) allowing root cause diagnosis. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>24c557e -
Fix 429 rate limiting: add 0.5s delay between per-event odds requests
15 back-to-back HTTP calls with zero delay triggered the API's burst rate limit (quota was only 30/20,000 — not exhausted). Adding 0.5s between each per-event request brings the call rate to ~2/sec. Total fetch time ~7.5s, cached for 300s so the delay is paid once per 5 minutes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>e342bd3 -
Fix all odds paths: per-event endpoint + regions + cache bypass
Upcoming path (Props page): - Add regions=us to per-event odds_params (documented as required; absence caused API to return bookmakers:[] silently, producing zero rows) - Lower _MAX_EVENTS 20→15 (covers full Opening Day slate) - Add event-ID dedup guard before each per-event request - Track 429s specifically in per-event except block - Replace final log with SUMMARY line (events_returned/attempted/rate_limited/rows) - Fix render_props fallback: remove `not raw_props.empty` guard so cached empty results are not bypassed, eliminating uncached re-fetch on every Streamlit rerun Live path (Dashboard): - Replace aggregate /odds endpoint (422 on player props) with two-step per-event approach: GET /events (commenceTimeFrom=now-6h to capture live games) → match teams via _canon_team → GET /events/{id}/odds with regions=us + requested markets - Function signature and row dict schema unchanged; all callers unaffected Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>7b92abe -
Add forensic diagnostic logging to fetch_all_upcoming_hr_props
Instruments the per-event odds path with full visibility into every step: - Step 1: log exact events request params (apiKey masked) - Step 2: log exact per-event odds params + HTTP status before raise_for_status - Response: log type, top-level keys, books returned, markets per book, outcome counts - Row-build loop: counters for bookmakers/markets/outcomes/rows plus per-reason skip counts - Sample first 3 outcomes verbatim (keys, name, description, price, point) No fixes applied. Diagnostic only — break point to be identified from log output. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>07e8342 -
Fix HR props 422: switch to per-event odds endpoint + cache Props fetch
The aggregate /odds endpoint returns HTTP 422 for batter_home_runs — player props require /events/{id}/odds. Replace fetch_all_upcoming_hr_props with a two-step approach: list events via /events, then fetch per-event odds for each game (capped at _MAX_EVENTS=20). Per-event failures log and continue so one bad game doesn't abort the batch. Add load_upcoming_hr_props() (ttl=300s) in app.py and thread it into render_props via raw_props kwarg, reducing credit burn from widget reruns from ~96 to 16 per 5-minute session on Opening Day. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>999cacf
-
Card Lab Pass 5: identity map + batter_id-based hitter query
- Build player_identity_map.parquet from pybaseball + MLBAM lookup + DB enrichment - Pitcher statcast_name resolved from ec.player_name (Last, First format) - Hitter statcast_name set to canonical_name; hitter cards now query by ec.batter = :batter_id - card_lab_pitcher_seasons.parquet and card_lab_hitter_seasons.parquet built from pybaseball pitching_stats/batting_stats with IP>0/AB>0 gates - get_player_card_window_df: add batter_id param for Hitter path (ec.batter = :batter_id) - card_lab_page.py: read batter_id from Parquet, pass to window query; no DB call for MLBAM ID - Collision-safe display_names; all validation checks pass (ALL PASS) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>84163a9
-
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
-
Post-patch cleanup: statcast season derivation + platoon lower bounds
- statcast.py: derive season from start_date instead of hardcoding "2026" - live_fair_simulator_v3.py: add max() lower bounds to opposite-hand platoon path Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>dca8dd7