At a glance
Every Grand Prix from 2021 to 2026
For every race, the model ranks every entrant and predicts the full finishing order. It is tested on races it never trained on, scored with ranking metrics, and compared across model types to find the ordering that holds up best.
The journey
Turning race prediction into a ranking problem
-
The question
“Who wins?” is the wrong question
Race prediction is usually framed as picking the winner and graded on accuracy. But a race produces a ranking, and the real problem is the whole order: who makes the podium, who scores points, who falls back.
So I framed it as learning to rank, the technique behind search engines. Each race is a group, the model orders the drivers in it, and it's graded on how close that order is to what actually happened.
-
The data
Seventy-one seasons of racing
I built the dataset from the public Ergast F1 archive: race results, race details and qualifying, joined by race and driver. That's 24,680 driver results across 1,021 Grands Prix, from 1950 to 2020.
Making seven decades of data consistent was its own challenge. Qualifying records only begin in 1994, and 43% of entries didn't finish. I ranked every retirement behind every finisher in its race, so each finishing order stays complete.
-
Features
What the model knows before the race starts
Each entry is described by what's known going into the race: the starting grid position and whether the driver starts from the pit lane, the qualifying result, and recent form, meaning the average finish over each driver's and each team's previous three races.
-
Models
Two ways to predict the order
I put two approaches head to head. A gradient-boosted model predicts each driver's finishing position, and the order follows from sorting. A learning-to-rank model (XGBoost) learns to order the drivers within each race directly.
Every model goes through five-fold cross-validation grouped by race, so no race is ever split between training and testing.
-
Scoring
Scoring the whole order, not just the winner
Instead of accuracy, each model is scored with NDCG and MAP, the metrics search engines use for ranked results, plus Spearman correlation between the predicted and actual order. NDCG@10 asks how good the predicted top ten is, weighting the front of the grid most.
-
What I found
The grid is most of the story
The starting grid carries the most weight, followed by driver and team form. Qualifying adds a little on top, since it largely decides the grid already.
That changes what “good” means. The real bar for a race model isn't a random guess. It's the simple rule that everyone finishes where they started, and a model is only useful where it beats that rule.
What I foundPick the baseline before you pick the model. For finishing orders, “finish = grid” is the one to beat, and it's far harder to beat than it looks.
-
Next
The rebuild, now under way
I'm rebuilding it with everything I've learned since. The new version pulls far richer data from the FastF1 API: lap times, race-control messages, circuit layouts and championship standings.
It will compute every feature strictly as of race morning, train on past seasons and test on the next one, report the grid baseline beside every result and use a modern ranking objective.
The first piece is already live: the pick at the top of this page runs on this season's data and keeps score against the pole-sitter after every race.