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
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.
0 of 7 parts marked complete on this device.
Every part of this course is marked complete on this device. The capstone below is the victory lap - and the quiz will tell you if anything slipped.
- Build a Statcast Exit-Velocity Leaderboard from ScratchYour first leaderboard from raw pitch-level truth.
- Make a Pitch-Location Heatmap in PythonLocation is strategy; heatmaps make it visible.
- Profile a Pitcher: Pitch Mix and Velocity with StatcastWhat a pitcher throws, and when - the arsenal quantified.
- Build a Hitter's Spray ChartWhere hitters actually hit it; shifts made sense the day you see it.
- Expected vs Actual: Find the Hitters Getting UnluckyLuck-hunting: expected stats against the box score.
- Pythagorean Wins: Expected Standings from Run DifferentialThe century-old formula that still anchors win expectation.
- Ranking Teams: Build a Power Ranking with rank()Fold 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…
RS and RA in a simple ratio - that's the whole formula, and it predicts next-season records better than current wins do.
2. A hitter whose expected stats are high but whose actual results are low is most likely…
Expected stats grade the quality of contact. Hitting the ball hard and having little to show for it is the signature of bad batted-ball luck.
3. Exit velocity measures…
It's the speed of the batted ball as it leaves the bat - the hitter's contribution, separated from where the ball happens to land.
4. Statcast data is…
Camera and radar tracking of every pitch and batted ball. It's measurement, which is why it settled arguments box scores couldn't.
5. A spray chart shows…
Batted-ball landing directions and depths. Pitch location lives in the heatmap tutorials - different chart, different question.
Where next: Statistics for Sports Data · Randomness, Inference & Simulation.