MLB betting analytics platform for daily wagering insights, model backtesting, and live odds recommendations.
-
Dashboard engine:
predictions.py(Streamlit home + 6 feature pages) -
UX pages:
pages/1_Today.py— Today (schedule & game drill-down, game context factors, weather + odds, deep dive link)pages/2_Stats.py— Stats (standings, team batting/pitching, leaders)pages/3_Matchup_Analysis.py— Matchup Analysis (H2H & rolling form)pages/4_Models.py— Models (features, model importances, calibration, Savant research)pages/5_Performance.py— Performance (pick history, P/L, bankroll/Kelly calculator)pages/6_Pick_6.py— Pick 6 (player prop probabilities, DK optimizer, season leaders)pages/7_Info.py— About (methodology, sources, tech stack)
-
Shared utilities:
page_utils.py(data loader, odds integration, plot helpers, formatting, sidebar) -
Data source directory:
data_files/(raw/CSVs +processed/Parquet)
predictions.pyhome:- Daily game schedule with lineups, SP matchup, status
- Per-game recommendations (Moneyline, Run Line, Over/Under)
- Odds harvest from ESPN live API (plus ESPN core event odds fallback)
- Live Odds API multi-book feed via
ODDS_API_KEY/st.secretsand auto fallback to saved CSV - Deep link button to game detail page on Today from main Home card
- Edge-based bet signal (✅ BET, ➡ LEAN, ⛔ PASS)
- Historical expected totals via Retrosheet
RS_per_G - One-click page navigation tiles to deeper analysis
- Standings and team-level offensive/defensive boxscore trends
- Batting/pitching leaderboards with year filters and interactive charts
- Head-to-head series history and 30/60/90-day rolling records
- Game Context factors in Today detail view:
- park factor, umpire park run environment, bullpen workload, platoon advantage, rest days, IL list
- Line movement, heavy favorite reactions, and situational splits
- Underdog ML: upset moneyline model for +120 plus dogs
- Spread model: -1.5 / +1.5 win probability
- Totals model: over/under total, using ensemble blending and LightGBM/XGBoost
- Feature importance, calibration plots, confusion matrix, ROC-AUC
- Daily retrain pipeline via GitHub Actions +
scripts/train_models.py
- Backtests with trailing performance metrics (ROI, sharpe, max drawdown)
- Pick history and entry-level policies (confidence tiers: HIGH/MEDIUM/LOW)
- Kelly criterion calculator (
src/bankroll/kelly.py) and bankroll growth simulation
- Added live current-season support for 2026 team batting, team pitching, standings, and player leaderboards.
- Added early-season supplement handling for
batting_current.parquet,pitching_current.parquet,gameinfo_current.parquet, andteamstats_current.parquet. - Added reference-data ingestion for FanGraphs Guts! weights, FanGraphs park factors, and the Chadwick player registry.
- Added live fallback logic in Stats and Pick 6 pages so current-year data appears before a full precompute refresh.
- Updated nightly ingestion workflow and scheduler to refresh reference data automatically.
- Custom ingestion scripts in
scripts/andsrc/ingestion/:fetch_savant_leaderboards.py,build_parquet_data.py,precompute_data.py- MLB Stats API, PyBaseball, Retrosheet, weather, odds sources
- Parquet conversion + schema validation in
src/data/(future-proof type-safe schema)
| Phase | Status | Focus |
|---|---|---|
| 00-01 | done | dataset architecture + source catalog |
| 02-03 | done | ingestion pipeline, schema, preprocessing |
| 04 | done | model training (XGBoost, LightGBM, ensembles) |
| 05 | done | evaluation dashboards, calibration, error analysis |
| 06 | done | picks engine + daily betting recommendations |
| 07 | done | optional API support (src/api/), data queries |
| 08 | done | Streamlit UI reshape to 7-page experience |
| 09 | in progress | CI/CD, Docker, deployment hardening |
| 10 | in progress | risk management, bankroll optimization, live edge widener |
- Clone repo:
git clone https://github.com/gmalbert/baseball-predictions.git cd baseball-predictions - Create venv and install:
python -m venv venv .\venv\Scripts\Activate.ps1 pip install -r requirements.txt
- Run training/ingestion once:
python scripts/build_parquet_data.py python scripts/train_models.py
- Launch site:
streamlit run predictions.py
- Uses ESPN scoreboard + per-game odds API (
sports.core.api.espn.com/v2/.../odds) - Caches for 30 minutes via
@st.cache_data - If no odds returned, app shows
Unavailableand the match remains in schedule only
- Follow style and lint rules (ruff formatting) and type hints
- Add tests in
tests/(mirrorssrc/structure) - Model changes should include analysis notebook findings and updated contingency backtests
For questions or feature requests, create an issue in GitHub with:
- Use case (model, market, UI)
- Sample game/date and your expected picker outcome
- Actual vs predicted output in the app
