Skip to main content
Trevor Grafton

PROJECT / ML

MLB Game Predictor

A daily Python pipeline that predicts MLB game winners and checks itself against the market.

Built
  • Python
  • DuckDB
  • scikit-learn
  • XGBoost
  • pandas
  • Source private: not published

Type
ML
Source
Private
Role
Solo personal project.
Built with
Python, DuckDB, scikit-learn

01 / Overview

Overview

  1. Load the data

    A bootstrap command downloads the 2023 to 2025 seasons and trains the models.

  2. Predict each day

    A daily run settles yesterday's predictions, refreshes data and predicts today's games.

  3. Check against the market

    Model probabilities are compared with, and blended toward, the market's probability.

02 / Context and problem

Context and problem

A long-running personal project: a single-file Python command-line tool with commands to bootstrap, run, train, predict and evaluate.

03 / My role

My role

Solo personal project.

04 / How it works

How it works

  1. Elo ratings

    Elo with a margin-of-victory multiplier and a starting-pitcher adjustment.

  2. Features

    Run differential, pitcher FIP, venue split, strikeout-minus-walk rate, bullpen FIP and park run and home-run factors.

  3. Models

    Calibrated logistic regression and XGBoost, plus a logistic stacker on time-series out-of-fold predictions.

  4. Blend

    The model probability is blended with the market probability in log-odds, weighted toward the market.

  5. Store and settle

    DuckDB holds games, predictions, pitcher and bullpen logs and weather; each run settles the previous day.

05 / Key decisions

Key decisions

Prune weak features

Weather and similar features had near-zero weight; pruning them raised honest accuracy from 0.563 to 0.571.

Blend toward the market

On settled games the model alone loses to the market on log loss.

06 / Results and numbers

Results and numbers

~57%

test accuracy, logistic model (time-ordered validation)

Measuredproject notes, 2026-06-10

52.9%

home team wins baseline, 2023 to 2025

Measuredproject notes, 2026-06-10

~366

games settled in daily runs, Aug 31 to Oct 1 2026 (approximate)

Measuredrun logs; repeat runs may re-settle a game

07 / Testing and quality

Testing and quality

  • No automated tests; an eval command reports performance and runs are logged.

08 / Limitations

Limitations

  • The market beats the model alone on log loss.
  • Pitcher FIP uses full-season numbers, which leaks future information into training.
  • The stacker's higher score was measured on its own training predictions, so it is not quoted.

09 / Next project

Next project

Clinic Referral Tracker (team project) →