← All projects

05 · Machine learning · 2023

F1 prediction

Predicting every position in a Grand Prix

Most race models stop at the winner. This one predicts the entire Formula 1 finishing order and is scored the way search engines score results. The rebuild is under way, and its first piece already makes a live pick for every race.

Complete · rebuild under way

Year
2023
Data
F1 results, 2021–2026
Models
Gradient boosting, XGBoost learning to rank
Scored with
Ranking metrics: NDCG, MAP, Spearman

Live prediction

Who wins the next race?

A live pick for the next Grand Prix on the calendar. It updates as the weekend unfolds, and all season it keeps score against the simplest rival: picking whoever starts on pole. Think you know better? Bet against it, purely for fun.

LiveLoading the calendar…

Just for fun

Bet against the model

Loading the grid…

Lap pace
1.0×

Why predict the whole finishing order?

A race result is an ordering of about twenty drivers. “Who wins?” throws most of that away. A model that gets P1 right and scrambles everyone behind isn't a good model, and accuracy alone will never tell you that.

So every model here is scored on the whole order, the way search engines score a page of results: the top places count most, but every position counts.

At a glance

Every Grand Prix from 2021 to 2026

6seasons of race results, 2021 to 2026 (2026 still in progress)
130Grands Prix
2,630individual driver results
30circuits raced

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

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. 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.

  7. 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.

Contact

Hiring? Let's talk.

I'm looking for full-time engineering roles in software, robotics and applied AI. Email is the fastest way to reach me.

pranch555@gmail.com