Capstone project
Same Question, Five Sports: Quantifying Home Advantage Across Leagues
A capstone: measure home advantage in five leagues, then count it fairly. Drop the draws and the Premier League goes from last to first.

Sports analytics, the hands-on way
Pull real MLB, NBA, soccer, NFL and NHL data, analyse it in Python, and build charts you made yourself - one focused tutorial at a time.
Start here Browse the 11 courses
Newest: Random Forests: A Column of Noise Ranks Third, part 12 of Machine Learning from Scratch, 14 October 2026.
11 courses · 101 tutorials · about 14 hours
Every tutorial belongs to exactly one course, in a deliberate order. Each course page carries a syllabus, a one-ZIP bundle of all its code and data, and progress you can tick off as you go.
Foundations and method
Zero to competent: install Python, learn pandas on real standings, and finish by building a league table from raw results.
Beginner
10 parts ~66 min total
Ten chart types, each built on real sports data, ending with the styling pass that makes a figure publishable.
Beginner to Intermediate
10 parts ~60 min total
The measurement toolkit: distributions, z-scores, percentiles, outliers, time series, Simpson's paradox — closing with what actually predicts winning.
Intermediate
13 parts ~88 min total
Monte Carlo seasons, bootstrap intervals, permutation tests, power, chi-square, Bayesian updating, regression to the mean — how to tell signal from luck.
Intermediate
11 parts ~109 min total
Twelve models and methods — gradient descent to random forests — every one implemented in pure numpy on real NBA data.
Advanced
12 parts ~139 min total
Read API docs like a developer, then pull your first real data from MLB, the NBA, StatsBomb, nflverse, the NHL and ESPN.
Beginner
7 parts ~65 min total
By sport
Exit velocity, pitch maps, spray charts, luck-hunting and Pythagorean wins — the richest free data in sports, put to work.
Intermediate
7 parts ~49 min total
Ratings tables, shot charts, zone efficiency, the three-point revolution, rest and back-to-backs — and an Elo system you build yourself.
Intermediate
9 parts ~69 min total
Pass maps, shot maps, heatmaps and pass networks from free pro event data — then a complete World Cup: scoring by stage and a Poisson scoreline model.
Intermediate
8 parts ~66 min total
EPA built by hand, quarterback efficiency, play-calling tendencies, receiver value, the fourth-down decision, spreads as probabilities and coaching tenure.
Intermediate
9 parts ~105 min total
Four NHL builds — shots, leaders, form, and the PDO luck flag — then the capstone: measuring home advantage across five leagues at once.
Intermediate
5 parts ~52 min total
A random forest in numpy on 923 NBA games: 500 trees vote, and the built-in importance ranks a column of random numbers third of six.
EM by hand on 24,947 NBA shot locations: six Gaussians find the court's zones, and 704 shots logged at the rim break the likelihood.
PCA by hand on 279 NBA players: volume and inside-outside carry 63% of ten box-score rates, and the shooting signal hides in the smallest component.
Regression discontinuity by hand on 13,904 NFL team-games: a close win buys nothing next week, and the balance check shows close games are not coin flips.
Fit Bradley-Terry ratings by hand with the MM algorithm: schedule-adjusted strength for every NFL team, and an honest out-of-sample test against win %.
Kendall's tau and Spearman's rho by hand on 26 NFL season pairs: order persists at a median tau-b of 0.205, and vanishes inside the playoff field.
Capstone project
A capstone: measure home advantage in five leagues, then count it fairly. Drop the draws and the Premier League goes from last to first.

Sport-agnostic skills - Python, pandas, plotting and data cleaning - that every other tutorial builds on.
MLB Statcast is the richest free data in sports. Pull it with pybaseball and build leaderboards, heatmaps and more.
The NBA's stats API is powerful but picky. Learn to pull it politely, then build standings, ratings and shot charts.
Free event data from StatsBomb plus xG from Understat let you analyse matches like a pro - no paid feed required.
nflverse opens up every NFL play. Compute EPA, compare quarterbacks, and learn the modern football-analytics toolkit.
The NHL's public API needs no key. Pull standings and play-by-play, then plot shots on a rink you draw yourself.
The build system only publishes a chart or a printed result if the tutorial's script actually produced it when it was run. Nothing is mocked up, and no number is typed in from memory - every printed block on the page is captured stdout from that finished script, which you can download and run yourself.
On most tutorials the Python blocks carry a Run button, powered by Pyodide, with the bundled real datasets pre-loaded - edit the code, break it, re-run it, nothing to install. Where code needs live APIs or specialist libraries the browser can't load, the page says so and hands you the finished script to run locally instead.
Every tutorial after the first declares its prerequisites and builds on the ones before it: foundations first, then the sport track you care about, then statistics and machine learning implemented from scratch. The learning path shows the whole spine.
Statcast, StatsBomb Open Data, nflverse, and the NBA and NHL public APIs. Every figure captions where its numbers came from - and, where they came from outside, when they were retrieved - and every finished script is downloadable - with the bundled sample data where the tutorial has one, and the live-API tutorials pull their own.