Free course · Intermediate · 7 parts · ~49 min

Baseball Analytics with Statcast

Exit velocity, pitch maps, spray charts, luck-hunting and Pythagorean wins — the richest free data in sports, put to work.

Baseball publishes more free, granular data than any other sport — every pitch, every batted ball, tracked. This course builds seven real Statcast and standings analyses: leaderboards, two kinds of pitch map, a spray chart, an expected-vs-actual luck audit, and the Pythagorean win expectation every front office still starts from.

Take the pybaseball first-pull tutorial (in Working with Real Sports APIs) first if you haven't; everything here assumes data is flowing.

What you'll be able to do

  • Build sortable Statcast leaderboards from raw pitch-level data
  • Map pitch locations and pitcher arsenals with real coordinates
  • Find over- and under-performing hitters with expected stats
  • Compute Pythagorean expected standings and spot lucky teams
Download the course bundle - every script + dataset, one ZIP

The bundle contains each part's finished script, the shared helpers, and the sample data they read, with a README listing the run order - the whole course works offline.

The syllabus

Pace: Parts 1-4 in any order once the pybaseball pull tutorial is done; 5-7 build on each other.

  1. Build a Statcast Exit-Velocity Leaderboard from ScratchIntermediate · ~5 minYour first leaderboard from raw pitch-level truth.
  2. Make a Pitch-Location Heatmap in PythonIntermediate · ~8 minLocation is strategy; heatmaps make it visible.
  3. Profile a Pitcher: Pitch Mix and Velocity with StatcastIntermediate · ~8 minWhat a pitcher throws, and when - the arsenal quantified.
  4. Build a Hitter's Spray ChartIntermediate · ~9 minWhere hitters actually hit it; shifts made sense the day you see it.
  5. Expected vs Actual: Find the Hitters Getting UnluckyAdvanced · ~9 minLuck-hunting: expected stats against the box score.
  6. Pythagorean Wins: Expected Standings from Run DifferentialIntermediate · ~5 minThe century-old formula that still anchors win expectation.
  7. Ranking Teams: Build a Power Ranking with rank()Intermediate · ~5 minFold it all together into one defensible ranking.

Check yourself

Five questions, graded on the page, nothing recorded anywhere - pick an answer and the explanation appears.

1. Pythagorean expectation predicts winning percentage from…

2. A hitter whose expected stats are high but whose actual results are low is most likely…

3. Exit velocity measures…

4. Statcast data is…

5. A spray chart shows…

Where next: Statistics for Sports Data · Randomness, Inference & Simulation.