51 min read

On the Sunday morning of the 2026 Italian Grand Prix, the Sector Four group chat was arguing about a number.

Chapter 26 — Predictive Modeling for F1: Race Outcome Prediction, Qualifying Forecasting, and Championship Simulation

On the Sunday morning of the 2026 Italian Grand Prix, the Sector Four group chat was arguing about a number.

Pierre Gasly had put the Alpine on pole at Monza. Aisha Bello had run the Box Box race model overnight, the gradient-boosting version we build in this chapter. It had been trained only on seasons up to 2025 and fed with everything known before the lights went out: the grid, Saturday's qualifying gaps, each team's recent pace, each driver's recent form and championship position. Its favourite was not the pole-sitter. George Russell, second on the grid, got a 46.2% chance of winning. Gasly got 23.8%, Charles Leclerc from third 15.7%.

Ray Castellano, the group's retired actuary, posted the base rate first. That is always his first move. Over 1994–2026, the pole-sitter won 51.6% of the races where we know who took pole. A pure "grid-slot history" forecast, which knows nothing except the starting slot, put Gasly at 51.3%. "Your model is betting against pole," he wrote. "It had better have a reason."

It had one. Over the previous five rounds Alpine's best qualifying lap had averaged 1.99% off the fastest team, Mercedes' only 0.10%. The model weighs the car as well as the slot. Then the race happened.

Andrea Kimi Antonelli started 19th and won. He is the only winner from 19th or lower on the grid since 1994 in the Jolpica results. The model had given him 2.9%. The grid-slot baseline had given him 0.12%. The race had a red flag on lap 3 and a virtual safety car on lap 28. Russell finished second, Verstappen third and Gasly seventh. Leclerc retired.

Ines: So the model was wrong.

Ray: The model said three in a hundred. Three-in-a-hundred things happen three times in a hundred. One race can't tell you it was wrong.

Aisha: It can tell us something, though. If the model's 3% horses win 10% of the time, it's broken. That's checkable.

Ray: Now you're talking like a bookmaker.

This chapter is about that check. We build forecasts for qualifying, for the race and for the championship from free data. We score them the way a bookmaker or a strategy department would. And we compare them, honestly, with the rules of thumb they have to beat. The headline is not flattering to machine learning. Saturday already tells you most of what Sunday will do. A model's job is to add the little that's left, to put honest probabilities on it, and to know when it doesn't know.

📊 Analytics Track: This is your chapter. Sections 26.3–26.6 build the feature table, four model families and the time-respecting validation. Section 26.8 builds the Plackett–Luce championship simulator. Every number comes from code/01–06 and project/boxbox/predict.py.

🎰 Betting Track: Read Sections 26.1, 26.2, 26.6 and 26.8 closely. The baselines and the calibration plots are what you need before Chapter 38 turns probabilities into prices. A model that picks winners but is badly calibrated is worthless to a bettor.


26.1 What a forecast is, and how to score one

A forecast is not a pick. "Russell wins" is a pick. "Russell 46%, Gasly 24%, Leclerc 16%, everyone else 14% between them" is a forecast. The difference matters because F1 outcomes are noisy enough that the best possible forecaster will be wrong about the winner roughly half the time. If you only grade picks, you can't tell a good forecaster having a bad season from a bad one having a lucky one.

So we use four scores, and we report all four throughout the chapter.

📐 Definition: Top-1 accuracy is the share of races in which the model's favourite won. Podium hit rate is the share of the three predicted podium names that finished in the top three, so 2 of 3 correct scores 0.667 for that race.

These two are easy to explain on television, and they are the numbers behind the often-quoted rule of thumb that a model "picks the winner 35–40% of the time and a podium finisher 60–70%". They ignore how confident the forecast was.

📐 Definition: The Brier score of a race forecast is the sum, over all drivers, of the squared difference between the forecast win probability and what happened: $$B = \sum_{i=1}^{N} (p_i - y_i)^2, \qquad y_i = 1 \text{ for the winner, } 0 \text{ otherwise.}$$

In plain English: every driver costs you the square of how far your probability was from the truth. A perfect forecast (100% on the winner) scores 0. Putting 100% on the wrong driver scores 2, the worst possible.

Worked number. Box Box's forecast for the 2026 Las Vegas Grand Prix, trained only on 2006–2025, gave Verstappen 0.659, Antonelli 0.136, Norris 0.095, Russell 0.073 and the rest of the field 0.037 between them. Verstappen won. The Brier score is $(1 - 0.659)^2 + 0.136^2 + 0.095^2 + 0.073^2 + \ldots = 0.116 + 0.018 + 0.009 + 0.005 + \ldots \approx 0.149$. For comparison, a know-nothing forecast that gives each of the 22 cars 1/22 scores $(1 - 1/22)^2 + 21/22^2 = 0.955$.

📐 Definition: The log loss (winner log loss) of a race forecast is $-\ln p_{\text{winner}}$, the negative natural log of the probability the forecast gave the driver who actually won.

In plain English: it measures how surprised you were. If you gave the winner 0.659, your loss is $-\ln 0.659 = 0.417$. If you gave him 0.029, as Box Box did for Antonelli at Monza, your loss is $-\ln 0.029 = 3.54$. The 22-car uniform forecast always scores $\ln 22 = 3.09$. Log loss punishes confident mistakes far more harshly than Brier does. That is why bookmakers and bettors care about it: it is the score that the Kelly criterion of Chapter 38 is built on.

Brier and log loss are proper scoring rules (Appendix E collects the book's statistical tools). You get the best expected score by reporting the probabilities you actually believe. Top-1 accuracy is not proper: it rewards a forecaster for rounding every favourite up to 100%.

The fourth tool is not a score but a picture: the reliability diagram (Section 26.6). Bin all forecasts by predicted probability and plot the observed win share in each bin. A calibrated forecaster's 30% picks win 30% of the time. Calibration is exactly what Aisha proposed to check at Monza.

⚠️ Common pitfall: quoting "my model picks the winner 60% of the time" without the baseline. In 2023 the championship leader won 18 of the 21 races in which there was a leader (85.7%, from the Jolpica standings). A model that copied him would have "picked the winner 86% of the time" that year without learning anything. Every accuracy in this chapter is printed next to the baselines of Section 26.2.

🔄 Check your understanding 1. Forecast A gives the eventual winner 0.40 and spreads the rest evenly. Forecast B gives him 0.20 but correctly names him as favourite because the field is very spread. Which has the better log loss for that race, and which "picked the winner"? 2. Why can't top-1 accuracy alone tell you whether a forecaster is calibrated?

Answer

  1. A: $-\ln 0.40 = 0.92$ beats B: $-\ln 0.20 = 1.61$. Both picked the winner if 0.20 was B's largest probability. Top-1 can't separate them; log loss can.
  2. Top-1 only checks whether the largest probability won. A forecaster who says 90% for every favourite and one who says 45% get the same top-1 score if they rank drivers the same way, but at most one of them can be calibrated.

26.2 The baselines every model must beat

Before fitting anything, we write down what you can predict with no model at all. code/01_baselines.py builds the feature table and computes the no-model forecasts from Jolpica results. It reproduces the book's baseline table exactly where the definitions overlap.

# code/01_baselines.py (excerpt): the pole -> win cross-check straight from Jolpica
pole = q[q.quali_position == 1][["year", "round", "driver_ref"]].rename(columns={"driver_ref": "pole"})
win = r[r.position == 1][["year", "round", "driver_ref"]].rename(columns={"driver_ref": "winner"})
pw = pole.merge(win, on=["year", "round"])
for lo, hi in [(1994, 2026), (2014, 2026), (2023, 2026), (2026, 2026)]:
    g = pw[pw.year.between(lo, hi)]
    print(f"pole -> win {lo}-{hi}: {wilson((g.pole == g.winner).sum(), len(g))}")
pole -> win 1994-2026: 51.6% (47.4-55.8), 278/539
pole -> win 2014-2026: 55.7% (49.7-61.5), 152/273
pole -> win 2023-2026: 62.6% (52.4-71.9), 57/91
pole -> win 2026-2026: 66.7% (45.4-82.8), 14/21

The pole-sitter won 51.6% of the 539 races since 1994 with a known pole. The rate is 55.7% in 2014–2026, 62.6% in 2023–2026, and 66.7% (14 of 21) in 2026 so far. These are the numbers that replace the often-quoted "predicting the winner is hard (~35–40% accuracy)". The simplest rule in the sport already beats that band, and it does so in 19 of the 21 seasons since 2006.

The other no-model rules, from the book's baseline table (Jolpica, Wilson 95% intervals):

baseline (picks before the race) 1994–2026 2014–2026 2023–2026 2026 (R1–R21)
pole-sitter wins 51.6% (47.4–55.8), 278/539 55.7% (49.7–61.5), 152/273 62.6% (52.4–71.9), 57/91 66.7% (45.4–82.8), 14/21
championship leader wins 39.0% (35.2–43.0), 230/589 42.7% (36.8–48.8), 111/260 43.7% (33.7–54.1), 38/87 35.0% (18.1–56.7), 7/20
previous race's winner wins 33.3% (29.6–37.2), 196/589 37.3% (31.7–43.3), 97/260 36.8% (27.4–47.3), 32/87 35.0% (18.1–56.7), 7/20
grid top 3 = podium (share of names) 63.4% (61.2–65.6), 1182/1863 68.6% (65.4–71.7), 562/819 66.7% (60.9–72.0), 182/273 60.3% (48.0–71.5), 38/63
pole-sitter on the podium 76.4% (72.7–79.8), 412/539 81.0% (75.9–85.2), 221/273 82.4% (73.3–88.9), 75/91 81.0% (60.0–92.3), 17/21

So the often-quoted "predicting a podium finisher is easier (~60–70%)" is also a baseline, not a model achievement. Naming the first three on the grid as the podium gets 68.6% of the names right in 2014–2026.

Two more facts about these rules matter for modelling.

  • Pole is not the same as grid slot 1. At the 2026 Las Vegas GP, Antonelli qualified fastest, and Jolpica lists him on pole, but he started sixth. The grid-1 starter (Verstappen) won. In 2026, "grid 1 wins" scores 71.4% (15/21) against "pole wins" 66.7% (14/21). The race model uses the actual grid, penalties applied, because that is the order the cars start in.
  • The leader rule is weak in 2026. The championship leader before the race won only 35.0% of races (7 of 20) this season. The 21 wins are spread over six drivers: Antonelli 9, Verstappen 4, Russell 3, Norris 3, Hamilton 1 and Leclerc 1. A forecast that leans on the championship table would have been fooled.

Bar chart of the share of starts converted into a win and a podium for each grid slot from 1 to 20, 2014 to 2026; P(win) drops from about 55 percent on pole to 23 percent from second and 10 percent from third, while P(podium) falls more slowly from 81 percent

📊 Figure (described): Win and podium shares by starting slot for 2014–2026 (273 GPs), with Wilson 95% whiskers. P(win) falls steeply: 54.9% from slot 1, 23.2% from slot 2, 9.9% from slot 3 and 3.7% from slot 4. P(podium) falls slowly through the first three slots (81.3%, 71.2%, 53.8%). The grid is already a strong forecast of the winner and an even stronger one of the podium.

The table behind that chart is a forecast in its own right, and a probabilistic one. If you give every driver the historical win rate of his grid slot and rescale so that the probabilities sum to 1 in each race, you have the grid-slot baseline. It is the model to beat in this chapter, because it is the forecast that Ray would make on a napkin. In code (predict.baselines) the slot rates are always computed from the training seasons only, so the 2026 baseline knows nothing about 2026.

Line chart of three no-model baselines by season, 2006 to 2026: pole-sitter wins (between 38 and 68 percent), championship leader wins (between 0 and 86 percent) and the grid top three as the podium (between 47 and 80 percent of names), with a grey band at 35 to 40 percent

📊 Figure (described): The three baselines by season, 2006–2026. Pole-to-win swings from 38% (2019) to 68% (2023), and the championship-leader rule swings far more widely, from none of 18 races in 2010 to 18 of 21 in 2023. The grey band marks the often-quoted 35–40% "winner prediction" figure. The pole rule is above 40% in 19 of 21 seasons. A season's own predictability moves every forecast more than any model choice does.

📺 On the broadcast: When the commentator says "pole is worth so much here", the data say pole is worth a lot almost everywhere. From 2014 to 2026 the pole-sitter won 55.7% of races and finished on the podium 81.0% of the time. The "front row lock-out" shot means even more: slots 1 and 2 together produced 78% of winners in that period (54.9% + 23.2%).

🧩 Productive struggle: Before reading on, write down your own answer. A model is given the grid plus every piece of form data you can think of. On 2014–2026, what top-1 accuracy do you expect it to reach out of sample? 55%? 65%? 75%? Write the number in the margin and why. We'll compare in Section 26.6.


26.3 Features: what we know before the lights go out

A feature is any number known before the race that might help predict it. The one rule that matters more than all the others is in the word before. Every feature in Box Box is built so that the row for race $r$ uses only races $< r$ and the qualifying session of race $r$ itself.

predict.build_features() produces one row per driver per Grand Prix from 2006 (the start of knockout qualifying) to 2026 R21: 8,851 driver-races in 420 GPs. It reuses four earlier chapters:

feature definition from
grid actual starting slot, penalties applied; pit-lane start = field size + 1 Jolpica results
quali_pos, quali_gap_pct qualifying position; best of Q1–Q3 vs the fastest driver (%), clipped at 5% Chapter 16
team_gap_trail team's best qualifying time vs the fastest team (%), mean of the previous 5 rounds Chapter 24
team_gap_type the same, over earlier rounds at circuits of the same speed type within the last 25 rounds Chapter 10 types
elo teammate-duel Elo (K = 32) before this round's duel Chapter 21
mate_gap_trail median teammate qualifying gap over the previous 8 rounds Chapter 21
quali_pos_trail, form_pos5, team_form5 mean qualifying position, mean finish and team best finish over the previous 5 races Jolpica
dnf_rate10 share of the driver's last 10 starts without taking the flag Jolpica
circuit_form the driver's mean finish at this circuit in earlier seasons Jolpica
champ_rank, pts_share championship rank and points ÷ leader's points before the race (round 1: previous season's final values) Jolpica + sprints
round_idx race number within the season Jolpica

Two data details from the qualifying table are worth knowing:

  • Jolpica's qbest_s column is empty in 2025, so the best time is the minimum of Q1, Q2 and Q3.
  • A driver who was fastest in Q2 but not in Q3 shows a gap of 0.000 even if he was not on pole.

The key move is the shift(1) inside every rolling feature:

# project/boxbox/predict.py (excerpt): every rolling feature looks only backwards
def _trail(df, key, col, window):
    """Mean of `col` over the previous `window` rows of the same `key` (rows sorted by race order)."""
    return df.groupby(key)[col].transform(lambda s: s.shift(1).rolling(window, min_periods=1).mean())

r = r.sort_values(["driver_ref", "race_seq"]).reset_index(drop=True)
r["form_pos5"] = _trail(r, "driver_ref", "pos", 5)          # finishes in the 5 races BEFORE this one
r["dnf_rate10"] = _trail(r, "driver_ref", "dnf", 10)
r["circuit_form"] = r.groupby(["driver_ref", "circuit_ref"]).pos.transform(
    lambda s: s.shift(1).expanding().mean())                 # earlier visits only

shift(1) moves every value down one race, so the rolling window ends at the previous race. Without it, the row for Monza would contain Monza's own result, and the model would "predict" what it had already been told.

Here is what the table holds for the front of the 2026 Las Vegas grid:

2026 Las Vegas GP - feature rows (sorted by grid):
abbreviation team_ref  grid  quali_pos  quali_gap_pct  team_gap_trail      elo  form_pos5  champ_rank  pts_share  pos
         VER red_bull   1.0        2.0          0.275           0.194 1926.643        1.6         2.0      0.715  1.0
         RUS mercedes   2.0        3.0          0.353           0.149 1745.193        9.4         3.0      0.672  9.0
         NOR  mclaren   3.0        4.0          0.374           0.536 1722.985        4.8         6.0      0.631  2.0
         HAD red_bull   4.0        5.0          0.744           0.194 1614.898        6.6         8.0      0.313 15.0
         LIN       rb   5.0        6.0          0.825           1.004 1445.218       13.2        11.0      0.097 20.0
         ANT mercedes   6.0        1.0          0.000           0.149 1684.435        2.8         1.0      1.000  4.0
         LAW       rb   7.0        8.0          1.230           1.004 1481.490        7.4         9.0      0.228 14.0
         GAS   alpine   8.0        9.0          0.709           1.845 1703.409       13.6        10.0      0.108  5.0

Read across Verstappen's row. He starts from slot 1 after qualifying second, 0.275% off the fastest time. Red Bull has been 0.194% off the fastest team over the last five rounds. His teammate Elo of 1926.6 is the highest in the field, and his last five finishes average 1.6. Antonelli's row shows the penalty case: fastest in qualifying (gap 0.000, quali_pos 1), starting from slot 6, and leading the championship.

How much does each feature tell us on its own? code/02_features.py computes, race by race, the Spearman rank correlation between each feature and the finishing order, and averages it over 2014–2026:

Mean within-race Spearman rho with finishing position (negative = higher value, better finish):
        feature    rho  n_races
  quali_gap_pct  0.642      272
      quali_pos  0.636      273
           grid  0.621      273
      pts_share -0.595      273
     champ_rank  0.595      273
quali_pos_trail  0.588      273
     team_form5  0.583      273
 team_gap_trail  0.582      273
  team_gap_type  0.566      273
      form_pos5  0.559      273
            elo -0.394      273
   circuit_form  0.382      273
     dnf_rate10  0.208      273
 mate_gap_trail  0.110      273

Horizontal bar chart of the absolute Spearman correlation of each feature with finishing position, 2014 to 2026; qualifying gap, qualifying position and grid slot lead at about 0.62 to 0.64, followed by championship and team-pace features near 0.58, then Elo at 0.39 and teammate gap at 0.11

📊 Figure (described): Each bar is the mean within-race rank correlation of one feature with the finishing order, over 273 GPs. Orange bars are known only after qualifying, blue bars before the weekend. The three qualifying-day features lead at 0.62–0.64. Championship position, team pace and recent form cluster just below at 0.56–0.60, because they all measure "fast car". The teammate features (Elo 0.39, teammate gap 0.11) are weak on their own: they rank drivers within teams, not across the field.

That last point is the most important lesson of the feature table. The car explains most of the spread in a race result (theme 6). A driver-only feature like teammate Elo is only useful combined with a team-pace feature, and even then the team does most of the work. Chapter 21 showed how hard it is to put a single number on the car's share; here we see the practical consequence for forecasting.

The pre-season problem

Trailing features have a blind spot: the first races after a rule change. Last season's pace order is a poor guide to a new car.

code/02_features.py measures this directly. For each round of the season, it computes the rank correlation between a team's trailing five-round qualifying gap and its gap at that round. It does this separately for the five seasons with a major technical rule change in our window and for the 16 stable seasons. The rule-change seasons are 2009 (aero simplified, slicks and KERS), 2014 (turbo hybrids), 2017 (wider cars), 2022 (ground effect) and 2026, per data/reference/history_eras.md.

Spearman(team gap over previous 5 rounds, team gap this round), by round of season:
reset  stable seasons  rule-change seasons
ridx
1               0.743                0.575
2               0.804                0.753
3               0.820                0.842
4               0.872                0.876
5               0.889                0.921

Line chart of the rank correlation between trailing team qualifying gap and the current round's gap, by round of the season 1 to 8, for stable seasons and rule-change seasons; the rule-change line starts lower at round 1 and catches up by round 3

📊 Figure (described): In stable seasons last year's order predicts the first race well (ρ = 0.743). After a rule change it predicts it much less well (ρ = 0.575). By round 3, two or three races into the new rules, the trailing window has refreshed and the two lines meet. Any pre-season forecast in 2027 should carry wide error bars for the first two rounds.

⚠️ Common pitfall: borrowing a descriptive tool as a feature. Chapter 24's development.smooth() uses a centred rolling median, which is exactly right for drawing a smooth development curve. As a forecasting feature, it is poison: the centred window at round 10 includes rounds 11 and 12. Section 26.5 measures what that leak does to the scores.

🔄 Check your understanding 1. Why does the feature table use the actual grid rather than the qualifying position as the main starting-order feature? 2. Teammate Elo has a within-race correlation of only 0.39 with finishing position, yet Chapter 21 found it predicts teammate duels well (the favourite won 66.1% of duels). How can both be true?

Answer

  1. Penalties move cars after qualifying. At 2026 Las Vegas the fastest qualifier started sixth. The grid is the order the race actually starts in; qualifying position stays in the table as a separate pace feature.
  2. Elo is built from teammate duels, so it ranks drivers only relative to their teammates. Across the field, a strong driver in a slow car finishes behind a weaker driver in a fast car, so the cross-field correlation is low. It becomes useful when combined with a team-pace feature.

26.4 Four model families, one interface

Box Box fits four kinds of model on the same feature table. All four end the same way: a win probability and a podium probability for every driver, normalised within the race.

Logistic regression models the log-odds of winning as a linear function of the features:

$$P(\text{win}_i) = \sigma\!\left(\beta_0 + \sum_k \beta_k x_{ik}\right), \qquad \sigma(z) = \frac{1}{1 + e^{-z}}.$$

In plain English: each feature pushes the odds up or down by a fixed factor, and the effects add on the log-odds scale. For example, if one standard deviation of qualifying gap carries $\beta = -1.2$, a driver 1 SD faster than average has $e^{1.2} = 3.3$ times the odds of winning, all else equal. (That coefficient is illustrative arithmetic, not a fitted value.)

Ordinal regression (proportional odds) models the whole finishing order, not just the win. We group finishes into six ordered bands: P1, P2, P3, P4–6, P7–10 and P11+. The model is:

$$P(\text{band}_i \le k) = \sigma\!\left(\theta_k - \sum_j \beta_j x_{ij}\right), \qquad \theta_1 < \theta_2 < \dots < \theta_5.$$

In plain English: there is one "speed score" per driver, $\sum_j \beta_j x_{ij}$, and a ladder of cut-points $\theta_k$. A higher score shifts the driver's whole finishing distribution towards the front. This is the textbook way to model finishing positions directly. P(win) is the probability of band 1, and P(podium) is the probability of bands 1–3. The model is fitted with statsmodels' OrderedModel.

Random forest averages 400 decision trees, each grown on a bootstrap sample of the rows and a random half of the features. Gradient boosting (HistGradientBoostingClassifier) adds 250 shallow trees one at a time, each one correcting the errors of the sum so far. Both learn interactions without being told about them, for example "slot 1 matters more when the team is fast". Both can overfit 400 rows a season if left unconstrained, so the leaves are kept large (≥ 5 rows for the forest, ≥ 25 for boosting) and the learning rate small.

The four models predict each driver separately, so their probabilities don't automatically sum to 1 within a race. predict_race() rescales them so that they do:

$$p_i^{\text{win}} = \frac{q_i}{\sum_{j \in \text{race}} q_j}, \qquad p_i^{\text{podium}} = \min\!\left(1, \; \frac{3\,r_i}{\sum_{j \in \text{race}} r_j}\right),$$

where $q_i$ and $r_i$ are the raw model outputs.

# project/boxbox/predict.py (excerpt): fit, predict, normalise within each race
def train(df, model="gbm", features=FEATURES_RACE):
    X = df[list(features)].to_numpy(float)
    if model == "ordinal":
        return dict(model=model, features=list(features), ordinal=_Ordinal().fit(X, df.band.to_numpy()))
    w = _make(model, "win").fit(X, df.win.to_numpy())          # P(win) classifier
    p = _make(model, "podium").fit(X, df.podium.to_numpy())    # P(podium) classifier
    return dict(model=model, features=list(features), win=w, podium=p)

def _normalise(d, col, total):
    s = d.groupby(["year", "round"])[col].transform("sum")
    return (d[col] * total / s.where(s > 0, 1)).clip(upper=1.0)

🔍 Why this works: A race has exactly one winner, so the probabilities must sum to 1. A per-driver classifier doesn't know that. It might give two dominant teammates 0.7 each because each one, taken alone, looks like a typical race winner. Rescaling within the race turns independent "how winner-like is this row?" scores into a competition among the cars actually present. It is a cheap approximation to a conditional logit, which builds the one-winner constraint into the likelihood. The Plackett–Luce model of Section 26.8 goes further and builds the whole finishing order into it.

We fit every model twice: on the full race feature set, and on a pre-qualifying set that drops grid, quali_pos and quali_gap_pct. The pre-qualifying model is the forecast you could publish on a Thursday. The gap between the two tells us exactly what Saturday is worth.

📋 Try it — Predict the race: the 2026 Las Vegas GP. The feature rows are in Section 26.3: Verstappen on slot 1 with the best recent form (1.6) and the field's top Elo; Russell on slot 2; Antonelli fastest in qualifying but on slot 6. Before you open the answer, write down your P(win) for Verstappen, Antonelli and Russell.

Box Box's answer (gradient boosting trained on 2006–2025)

text abbreviation team_ref grid quali_pos p_win p_podium pred_rank pos VER red_bull 1.0 2.0 0.659 0.809 1.0 1.0 ANT mercedes 6.0 1.0 0.136 0.381 2.0 4.0 NOR mclaren 3.0 4.0 0.095 0.479 3.0 2.0 RUS mercedes 2.0 3.0 0.073 0.635 4.0 9.0 score: favourite won = True, podium names hit = 0.67, Brier = 0.149, -ln p(winner) = 0.416

Verstappen at 0.659 is far above the grid-slot rate for pole (about 0.55). That is the effect of his form and Elo. Antonelli at 0.136 is far above the slot-6 rate (2.6% in 2014–2026), because his car and championship position say "fast". Russell gets less than his slot alone would give, because his recent finishes averaged 9.4. Verstappen won; Norris (P2) and Piastri (P3, from slot 17) made the podium. The predicted podium of Verstappen, Russell and Norris hit 2 of 3.


26.5 Validation that respects time

The most common way to fool yourself with a race model is to test it on the wrong data. Box Box uses one scheme only: walk-forward validation.

📐 Definition: Walk-forward (time-respecting) validation: for each test season $Y$ from 2014 to 2026, train on seasons 2006 … $Y-1$ and predict every race of $Y$. No race in the test season, and nothing after it, ever influences the fitted model.

# project/boxbox/predict.py (excerpt)
def walk_forward(df, model="gbm", features=FEATURES_RACE, test_years=range(2014, 2027), min_train_year=2006):
    out = []
    for y in test_years:
        tr = df[(df.year >= min_train_year) & (df.year < y)]     # the past only
        te = df[df.year == y]
        out.append(predict_race(train(tr, model, features), te))
    return pd.concat(out, ignore_index=True)

This is how a forecast would really have been made. In March 2026 you had 2006–2025 to learn from and nothing else. The design is slightly conservative: within a season, the model's parameters are frozen. Its features still update race by race, because form, Elo and team pace are recomputed before every round. Retraining after every round would add a little information at a cost of 21 fits per season. Exercise C5 asks you to measure whether it is worth it.

What happens if you ignore time? code/05_leakage.py fits the same gradient-boosting model, on the same 2014–2026 test races, under three dishonest schemes:

  1. grouped 5-fold by race: whole GPs are held out together, but the training folds include seasons after the test race;
  2. random 5-fold over rows: drivers from one Grand Prix are scattered across folds, and future seasons are in training;
  3. walk-forward with two leaky features: - a centred five-race rolling team gap (the Chapter 24 smoothing trap, which uses the next two races' qualifying); - the driver's end-of-season championship rank.
Gradient boosting, test rows 2014-2026 R21 (273 GPs), four validation schemes:
  Walk-forward by season (honest)                      top1 0.549  podium 0.680  Brier 0.6051  logloss 1.304
  Grouped 5-fold by race (future seasons in training)  top1 0.560  podium 0.679  Brier 0.6162  logloss 1.301
  Random 5-fold over rows                              top1 0.553  podium 0.686  Brier 0.6146  logloss 1.302
  Walk-forward + leaky features                        top1 0.527  podium 0.702  Brier 0.5946  logloss 1.242

Horizontal bar chart of winner top-1 accuracy for one gradient-boosting model under four validation schemes on the same 273 races, with log loss annotated: honest walk-forward 54.9 percent and log loss 1.30, grouped and random folds within about one point, and walk-forward with leaky features 52.7 percent but the best log loss, 1.24

📊 Figure (described): One model, four ways of testing it. The two cross-validation schemes that train on the future score about the same as the honest walk-forward (top-1 within 1.1 points, log loss within 0.003). Adding the two leaky features improves log loss from 1.304 to 1.242 and podium hits from 0.680 to 0.702. A dotted line marks the pole-sitter pick (55.7%) for reference.

This result surprised us, and it is worth reading carefully, because it is not the usual textbook story.

  • Random cross-validation barely flatters this model. The features that carry most of the signal are same-day qualifying numbers. They contain no future information whichever way you split the rows, so mixing seasons doesn't help much. On this problem the shuffled scheme gave roughly the right answer by luck. On a problem where the target drifts, for example degradation across tyre generations, it would not.
  • Leaky features are the real danger. They cut log loss by 0.062. That is almost half of the model's entire honest gain over the grid-slot baseline (1.439 → 1.304, a gain of 0.135; Section 26.6). If you had added the centred team trend "because it's smoother", you would have reported an improvement half the size of everything the model achieves, and you could never have collected it on a real Sunday.
  • The leak shows up in probabilities more than in picks. Top-1 accuracy actually fell (0.549 → 0.527) while log loss and podium hits improved. The model became more confident about which three cars would be at the front: the end-of-season rank "knows" who the top three are.

⚠️ Common pitfall: judging leakage by top-1 accuracy. With 273 test races, one more or one fewer correct favourite moves top-1 by 0.4 points, so that score is too coarse to reveal a leak. Use log loss or Brier on the same races, and always compare against the honest walk-forward number.

🔄 Check your understanding 1. You add "the driver's mean finishing position this season" as a feature, computed with groupby(["year", "driver_ref"]).pos.transform("mean"). What is wrong, and how do you fix it? 2. Why is "grouped by race" cross-validation better than "random rows", yet still not acceptable here?

Answer

  1. transform("mean") over the whole season includes this race and all later races of the season. That is a leak. Use shift(1) followed by an expanding mean, so that only earlier races count.
  2. Grouping keeps the 20–22 drivers of one GP together, so the model can't learn this race's outcome from teammates' rows. But the training folds still contain later seasons: a 2016 test race is predicted by a model that has seen 2017–2026. A real forecaster never has that.

26.6 The honest scoreboard

code/03_race_models.py runs every model through walk-forward validation, 2014–2026: 273 GPs and 5,567 driver-races, each predicted by a model that had never seen its season. Here is the pooled result, next to the no-model picks.

=== 2014-2026 (273 GPs) ===
  Pole-sitter pick                       top1 0.557   podium(grid top 3) 0.687
  Championship-leader pick               top1 0.431
  Grid-slot history (baseline)           top1 0.549   podium 0.687   Brier 0.6370   logloss 1.439   mean p(fav) 0.502
  Logistic regression                    top1 0.582   podium 0.683   Brier 0.6020   logloss 1.292   mean p(fav) 0.485
  Ordinal regression                     top1 0.549   podium 0.683   Brier 0.6687   logloss 1.436   mean p(fav) 0.323
  Random forest                          top1 0.542   podium 0.681   Brier 0.5986   logloss 1.275   mean p(fav) 0.506
  Gradient boosting                      top1 0.549   podium 0.680   Brier 0.6051   logloss 1.304   mean p(fav) 0.572
  Logistic, pre-qualifying               top1 0.473   podium 0.612   Brier 0.6875   logloss 1.496   mean p(fav) 0.418
  Gradient boosting, pre-qualifying      top1 0.440   podium 0.604   Brier 0.7174   logloss 1.593   mean p(fav) 0.450

(The leader pick in this table is 0.431 because two co-leaders on equal points both count as the pick; the book's baseline table, which breaks such ties, gives 42.7%.)

Three-panel horizontal bar chart comparing seven forecasts on top-1 accuracy, Brier score and log loss over 273 races: the four post-qualifying models cluster near the grid-slot baseline on top-1 (0.54 to 0.58) but improve on Brier (0.60 against 0.64) and log loss (1.28 to 1.30 against 1.44), except the ordinal model; the two pre-qualifying models are clearly worse on all three

📊 Figure (described): The grid-slot baseline is in grey, post-qualifying models in blue, and pre-qualifying models in green. On picking winners, every post-qualifying model sits within 3.3 points of the baseline's 0.549. On the probability scores, logistic regression, random forest and boosting beat the baseline clearly: Brier 0.599–0.605 against 0.637, log loss 1.275–1.304 against 1.439. The ordinal model does not. The pre-qualifying models lose about 11 points of top-1 and 0.20–0.29 of log loss.

So, to settle the rule of thumb: out of sample, F1 race-winner models pick the winner about 54–58% of the time over 2014–2026, and 63–64% in 2023–2026. Podium models get about 68% of the names right. Neither figure is the "35–40%" or "60–70%" of the rule of thumb, and, more importantly, neither is meaningfully better than the pole-sitter pick. The paired bootstrap (2,000 race resamples) puts it formally:

Paired bootstrap (2,000 race resamples, seed 42), model top-1 minus pole-sitter top-1, 2014-2026:
  Logistic regression                    top1 +0.026 [-0.022, +0.073]   podium vs grid top 3 -0.005 [-0.026, +0.016]
  Random forest                          top1 -0.015 [-0.055, +0.026]   podium vs grid top 3 -0.006 [-0.021, +0.006]
  Gradient boosting                      top1 -0.007 [-0.051, +0.037]   podium vs grid top 3 -0.007 [-0.023, +0.007]
  Gradient boosting, pre-qualifying      top1 -0.117 [-0.194, -0.040]   podium vs grid top 3 -0.083 [-0.115, -0.053]
  Brier, gradient boosting minus grid-slot baseline: -0.0320 [-0.0655, -0.0014] (negative = better)
  Log loss, gradient boosting minus grid-slot baseline: -0.135 [-0.251, -0.025]
  Brier, logistic minus grid-slot baseline: -0.0350 [-0.0639, -0.0051]

Read the intervals, not the point estimates.

  • Picks: every post-qualifying model's top-1 difference from the pole pick includes zero. The best, logistic regression at +2.6 points, has an interval from −2.2 to +7.3.
  • Probabilities: the Brier and log-loss improvements over the grid-slot baseline exclude zero for boosting (log loss −0.135 [−0.251, −0.025]) and for logistic regression (Brier −0.035 [−0.064, −0.005]).
  • Saturday: the pre-qualifying model is significantly worse than the pole pick, by 11.7 points [−19.4, −4.0].

The models' value is not in picking a different winner. It is in better-calibrated probabilities: knowing that a pole-sitter in a dominant car is a 70% shot and one in a midfield car is a 25% shot, where the grid-slot table says 51% for both. That is what a strategist planning risk and a bettor pricing a market need. It is not what a headline needs.

🧩 Productive struggle, revisited: compare the number you wrote in Section 26.2 with the scoreboard. Most people guess 65–75% for a model with full information. The data say about 55%, the same as pole. Why? Write one sentence before reading on.

One answer

Qualifying already summarises almost everything the form features know: car pace, driver pace and the circuit's demands, measured on the same weekend. What is left after the grid is the unpredictable part of a race: starts, safety cars, strategy, reliability, weather. No pre-race feature can see that. Section 26.9 counts it.

By season

Line chart of top-1 accuracy by test season 2014 to 2026 for the pole-sitter pick and three models; all lines move together, from about 38 to 47 percent in 2019 to 68 to 86 percent in 2023, with the pre-qualifying model falling to 19 to 21 percent in 2025 and 2026

📊 Figure (described): Each season is predicted by models trained only on earlier seasons. All four lines rise and fall together. 2019 is the hardest year for the pole pick (38.1%); 2023 is the easiest (68.2% for pole, 77–82% for the post-qualifying models). The pre-qualifying boosting model collapses in 2025 (20.8%) and 2026 (19.0%), seasons in which last year's order and the championship table were poor guides to the next race.

By season:
      races   pole  logit_top1  logit_podium  gbm_top1  gbm_podium  gbm_pre_top1  gbm_pre_podium  grid3
2019     21  0.381       0.429         0.746     0.381       0.746         0.476           0.651  0.762
2023     22  0.682       0.818         0.652     0.773       0.606         0.864           0.500  0.636
2024     24  0.500       0.458         0.625     0.458       0.597         0.375           0.528  0.667
2025     24  0.667       0.625         0.708     0.625       0.792         0.208           0.667  0.750
2026     21  0.667       0.619         0.619     0.667       0.603         0.190           0.460  0.603

Three things stand out.

  • 2023 is a different sport. With one car dominant, every model and baseline scored its best season. The pre-qualifying model even hit 86.4%: once you know the car, you know the winner.
  • 2024–2026 punish the form features. In 2024 four teams won races, and the post-qualifying models were worse than pole (45.8% against 50.0%).
  • 2026 pre-qualifying is the cautionary tale. At 19.0%, the Thursday boosting model made Russell its favourite 11 times, Antonelli 8 times and Verstappen twice; only 4 of those 21 favourites won. It found the right car but could not separate the Mercedes drivers, and it had no way to know which weekends Verstappen's Red Bull would be quick.

Are the probabilities honest?

Reliability diagram of predicted win probability against observed win share for logistic regression, gradient boosting and the grid-slot baseline, pooled 2014 to 2026; boosting tracks the diagonal from 0 to 0.55 and runs slightly below it at 0.67 and 0.81, logistic regression sits above the diagonal around 0.5

📊 Figure (described): Forecasts pooled over 5,567 driver-races are binned by predicted win probability (bins with at least 10 forecasts; Wilson whiskers). Gradient boosting is close to the diagonal up to 0.55. Above that it is slightly over-confident: 0.667 predicted against 0.614 observed (n = 70) and 0.810 against 0.714 (n = 28). Logistic regression is under-confident in the 0.45–0.60 bin: 0.510 predicted, 0.634 observed (n = 131). Its Wilson interval excludes the diagonal.

Reliability, Gradient boosting:
           bin    n  wins  predicted  observed
  (0.02, 0.05]  281    13      0.031     0.046
   (0.05, 0.1]  191    14      0.072     0.073
    (0.1, 0.2]  200    25      0.145     0.125
    (0.2, 0.3]   88    24      0.247     0.273
   (0.3, 0.45]  137    48      0.372     0.350
   (0.45, 0.6]  136    72      0.525     0.529
   (0.6, 0.75]   70    43      0.667     0.614
   (0.75, 1.0]   28    20      0.810     0.714

Back to Monza. Aisha's test was: do the model's 3% shots win about 3% of the time? The (0.02, 0.05] bin holds 281 forecasts with a mean of 3.1%; 13 of them won, which is 4.6%. A Wilson interval for 13/281 runs from about 2.7% to 7.8%. The 3.1% forecast sits inside that interval, so the bin behaves roughly as advertised. If anything the model is a shade stingy with long shots; case study 1 shows that over all bins below 10% it predicted 30.4 wins and saw 41. One upset is not evidence against a model; a bin of upsets would be.

What the model leans on

Horizontal bar chart of permutation importance for the gradient-boosting model tested on 2023 to 2026: grid slot raises the Brier score by 0.135 when shuffled, qualifying position by 0.073, then points share, team qualifying gap and recent form by 0.016 to 0.024; several features have importance near zero or slightly negative

📊 Figure (described): We shuffle each feature among the drivers of the same race and measure how much the Brier score worsens. The model was trained on 2006–2022 and tested on 2023–2026 (91 GPs), with 10 shuffles per feature. The grid slot is worth 0.135 of Brier on its own, and qualifying position another 0.073. The next tier is points share (0.024), the team's trailing qualifying gap (0.023) and recent form (0.016). Championship rank, circuit history and trailing qualifying position are worth nothing once the other features are present, because they duplicate information.

📺 On the broadcast: The pre-race graphic that shows "wins at this circuit" is the least useful number on screen. In our model, a driver's past finishes at the circuit (circuit_form) add nothing once the grid and recent pace are known. The permutation importance is −0.001 ± 0.006.

🔄 Check your understanding 1. Gradient boosting's top-1 accuracy (0.549) equals the grid-slot baseline's, yet its log loss is 0.135 better. In one sentence, what is the model doing that the baseline is not? 2. Logistic regression gives 0.51 to drivers who win 63% of the time. Is that a problem for a bettor? For a strategist?

Answer

  1. It ranks the drivers almost the same way but puts different amounts of confidence on its favourites: more when the car is dominant, less when it isn't. That earns proper-scoring-rule credit without changing many picks.
  2. For a bettor, yes: a calibration error that size means systematically under-pricing strong favourites, and it is costly. For a strategist choosing between strategies, less so. The decision usually depends on the ranking of outcomes, and only an error that changes the decision costs anything.

26.7 Forecasting Saturday

If the grid carries most of Sunday's information, the next question is how well we can forecast the grid. Kenji Mori, Sector Four's sim racer, plans his online-league qualifying around exactly this: who will be quick, and by how much?

code/04_qualifying_forecast.py predicts each driver's qualifying gap to the fastest driver (%, best of Q1–Q3, clipped at 5%) from pre-weekend features only:

  • the team's trailing qualifying gap, and its gap at the same circuit type;
  • teammate Elo and the driver's trailing teammate gap;
  • trailing qualifying positions;
  • the round of the season.

Two regressors are trained walk-forward, 2014–2026 (272 rounds): a ridge regression, which is linear least squares with a small penalty that shrinks the coefficients, and gradient boosting. Ranking the predicted gaps gives a predicted qualifying order.

Qualifying forecasts: 272 rounds, 5,473 driver-rounds (2014-2026 R21)
  Previous round's qualifying order    pole 0.357  top-10 names 0.758  Spearman 0.685  MAE 3.32 places
  Ridge regression                     pole 0.408  top-10 names 0.790  Spearman 0.773  MAE 2.80 places
  Gradient boosting                    pole 0.434  top-10 names 0.786  Spearman 0.763  MAE 2.87 places

The naive rule, "same order as last race", finds the pole-sitter 35.7% of the time and puts 75.8% of the right names in the top 10. The models improve every measure. Pole rises to 40.8–43.4%, the rank correlation from 0.685 to 0.763–0.773, and the mean absolute error falls from 3.32 to 2.80–2.87 places. The improvement comes from averaging over five rounds instead of one, and from the circuit-type adjustment.

On 2023–2026 we can also use something Jolpica doesn't have: practice pace. For each qualifying session we take each driver's best lap in the last session that ran before it. That was FP3 in 66 rounds, sprint qualifying in 18 and FP1 in 6 (2023 sprint weekends had qualifying on Friday).

2023-2026: 90 rounds; last session before Q: {'FP3': 66, 'SQ': 18, 'FP1': 6}
  Previous round's order               pole 0.311 (28/90)  top-10 names 0.750  Spearman 0.630  MAE 3.72
  Gradient boosting (pre-weekend)      pole 0.356 (32/90)  top-10 names 0.773  Spearman 0.708  MAE 3.32
  Last practice / SQ order             pole 0.404 (36/89)  top-10 names 0.779  Spearman 0.701  MAE 3.17
  Model + practice (equal blend)       pole 0.433 (39/90)  top-10 names 0.798  Spearman 0.751  MAE 2.94

Two-panel bar chart of pole hit rate and top-10 hit rate for four qualifying forecasts on 2023 to 2026: previous round's order 0.31 and 0.75, the pre-weekend boosting model 0.36 and 0.77, last practice order 0.40 and 0.78, and an equal blend of model and practice 0.43 and 0.80

📊 Figure (described): On 90 rounds of 2023–2026, the last practice session alone finds the pole-sitter more often (36 of 89 rounds with data) than the pre-weekend model (32 of 90). Blending the two, by averaging their within-round standardised scores with equal weights and no fitting, does best on every measure: 39 poles, 79.8% of top-10 names, Spearman 0.751.

Practice is noisy because teams run different fuel loads and programmes, so a practice order is a biased measurement of qualifying pace. The pre-weekend model is a stale one. Combining a stale estimate with a noisy, fresh one beats either: that is the logic of every Kalman filter, and of every strategist who looks at FP2 long runs and last year's notes.

How hard is pole specifically? Even the best blend finds it in fewer than half the rounds. The book's pole-margin table answers that: the median gap from pole to P2 was 0.109–0.175 s in the 2023–2026 seasons, and 32–39% of poles each season were decided by less than 0.1 s. At the very front, the order is close to a coin toss among two or three cars. Chapter 16 found the cut lines just as tight, with a median 0.056 s between the last car through Q1 and the first car out.

At the 2026 Las Vegas GP the pre-weekend model ranked Antonelli first, and he took pole. It ranked Verstappen only fifth, and he qualified second:

abbreviation team_ref  quali_pos  model_rank  prac_rank   gbm  quali_gap_pct
         ANT mercedes        1.0           1        2.0 0.235          0.000
         VER red_bull        2.0           5        6.0 0.651          0.275
         RUS mercedes        3.0           2        1.0 0.342          0.353
         NOR  mclaren        4.0           6        3.0 0.673          0.374

📋 Try it — Compare these drivers: run code/04_qualifying_forecast.py, then filter the predictions to Hamilton and Leclerc in 2026. Which driver's qualifying position does the pre-weekend model predict better (lower mean absolute error in places)? Chapter 21 found their 2026 teammate gap was only 0.047% with 10 of 21 rounds within 0.1%. Predict before you compute: should the model separate them at all?


26.8 Simulating the rest of a championship

A race model gives probabilities for one Grand Prix. A championship needs a joint model of every remaining race, and points are awarded on the whole finishing order, not just the win. Box Box uses the Plackett–Luce model for that.

📐 Definition: In the Plackett–Luce model each driver $i$ has a strength $\theta_i$ (a log-scale number). The probability of an observed finishing order $(1, 2, \dots, m)$ is built by choosing the winner, then the runner-up from those left, and so on: $$P(\text{order}) = \prod_{k=1}^{m} \frac{e^{\theta_k}}{\sum_{j \ge k} e^{\theta_j}}.$$

In plain English: the winner is drawn with probability proportional to $e^{\theta}$ among all finishers. Second place is drawn the same way among those left. Two drivers' head-to-head odds are $e^{\theta_a - \theta_b}$ whatever else is in the race. With $\theta_a - \theta_b = 0.65$, driver $a$ finishes ahead $e^{0.65}/(1 + e^{0.65}) = 0.66$ of the time when both finish.

It is the natural extension of the Elo/Bradley–Terry idea from Chapter 21 from duels to whole fields. It is also the likelihood behind the rank-ordered models in van Kesteren & Bergkamp (2023).

predict.fit_strengths() estimates $\theta$ by maximum likelihood from the finishing orders of a season so far, with three choices:

  1. Only cars that took the flag are in the order. Retirements are modelled separately by a DNF probability.
  2. Recency weighting: race $r$ gets weight $0.5^{(\text{races ago})/h}$ for a half-life $h$.
  3. A small ridge penalty ($0.05\,\theta^2$) keeps a driver with three finishes from getting an extreme strength.

⚠️ Common pitfall: using Jolpica's is_classified as "finished". A car that retires after covering 90% of the distance is classified: Norris's retirements at the 2025 Canadian GP (66 laps completed) and the 2025 Dutch GP (64 laps) both appear as "Retired", classified 18th. Our first version fed those into the Plackett–Luce order as genuine 18th places. With five races left in 2025, it rated Norris's strength at 0.79, against 2.47 for Piastri, and gave Piastri a 97.8% title chance. With the finished flag the strengths are close, and the title probability is 61/38 (case study 2). One flag, one wrong column, a completely different forecast. predict.is_dnf() now does this correctly.

Choosing the half-life without peeking

How much should last weekend count against the first race of the season? We let the data decide, time-respecting again. code/06_championship_sim.py takes every race from round 6 onward in 2014–2026 (208 races). For each one it fits strengths on that season's earlier races only, then scores the log-probability of the race's actual finishing order:

Mean log-probability of the next race's finishing order (higher = better):
      mean_lp  races  gain_vs_uniform
hl
2     -28.816    208            4.732
4     -28.325    208            5.222
6     -28.247    208            5.300
10    -28.244    208            5.304
20    -28.285    208            5.262
None  -28.371    208            5.176
  uniform (every order equally likely): -33.547

Line chart of the log-probability gain over a random finishing order against the recency half-life (2, 4, 6, 10, 20 races and equal weights), for 2014 to 2026 and for 2026 alone; both curves rise steeply from 2 to 6 races and are nearly flat beyond

📊 Figure (described): The fitted strengths predict the next race's order 4.7 to 5.3 nats better than chance (2014–2026). A two-race memory is clearly worse. From six races to equal weights the curve is flat: the best is 10 races (5.304), a hair ahead of 6 (5.300). In 2026 alone the best value is 6 races, but again by a tiny margin. We use $h = 10$.

The 2026 standings after round 21

First, arithmetic. The standings come from Jolpica GP and sprint results. They match the book's season table: Antonelli 402, Verstappen 304, Hamilton 267; Mercedes 666, Ferrari 517, Red Bull 440.

 position     driver_ref team_ref  points  wins
        1      antonelli mercedes   402.0     9
        2 max_verstappen red_bull   304.0     4
        3       hamilton  ferrari   267.0     1
        4        russell mercedes   264.0     3
        5         norris  mclaren   264.0     3
        6        leclerc  ferrari   250.0     1

Constructors after R21:
 position     team_ref  points  wins
        1     mercedes   666.0    12
        2      ferrari   517.0     2
        3     red_bull   440.0     4
        4      mclaren   431.0     3
        5           rb   114.0     0
        6       alpine    87.0     0

Still available: 2 GPs, no sprints (calendar_2026.csv) -> 50 points per driver, 86 per team (25+18 x 2).
  Mercedes lead over Ferrari: 149 > 86 -> constructors' title settled
  Antonelli lead over Verstappen: 98 > 50 -> drivers' title settled
  Verstappen - Hamilton (P2 vs P3): 37; Ferrari - Red Bull (P2 vs P3): 77; Red Bull - McLaren: 9

Both titles are decided. Antonelli clinched the drivers' championship at Mexico City (R19). Mercedes' 149-point lead is more than the 86 points a team can still score in Qatar and Abu Dhabi, so the constructors' title is also mathematically settled. What the simulator can still say something about is the places behind them. The drivers' P2 and P3 are open: Verstappen's 37-point margin over Hamilton is less than the 50 available, and three drivers sit within 17 points of Hamilton. The constructors' P3 is open too, with Red Bull only 9 points ahead of McLaren. Chapter 33 shows why the order of constructors' places is worth real prize money.

Strengths and reliability

Plackett-Luce log-strengths, 2026 R1-R21 (half-life 10); 90% race-bootstrap interval (200 reps):
  max_verstappen   +3.32  [+2.93, +4.20]
  antonelli        +2.67  [+1.62, +3.97]
  norris           +2.36  [+1.75, +3.22]
  hamilton         +2.12  [+1.84, +2.77]
  leclerc          +2.07  [+1.55, +2.97]
  russell          +1.70  [+1.19, +2.44]
  piastri          +1.03  [+0.43, +2.03]
  P(Antonelli ahead of Verstappen | both finish) = 0.345

Dot plot with interval bars of 2026 Plackett-Luce strengths for the top 14 drivers, Verstappen highest at about 3.3, Antonelli and Norris next, with overlapping 90 percent bootstrap intervals

📊 Figure (described): Recency-weighted finishing-order strengths after R21, coloured by team, with 90% race-bootstrap intervals. Verstappen rates highest (+3.32), ahead of the champion Antonelli (+2.67). That reflects the recency weighting and the finishing orders of the later races, not the points table. The intervals of the top five overlap, and Russell's (+1.19 to +2.44) is wide. The bootstrap resamples the season's races, so the intervals carry the real race-to-race variation.

The strength table and the standings tell different stories on purpose. Antonelli has 98 more points than Verstappen, but with a 10-race half-life the model weights recent races most, and recent finishing orders favour Verstappen. Over R12–R21, Verstappen averaged 18.4 GP points per race, Antonelli 17.3 and Norris 12.9. A strength is a forecast of the next race, not a verdict on the season.

DNF probability per car per race is the team's 2026 rate, shrunk towards the field rate:

$$\hat p_{\text{team}} = \frac{\text{DNF}_{\text{team}} + 20\,\bar p}{\text{starts}_{\text{team}} + 20}, \qquad \bar p = \frac{83}{453} = 0.183.$$

In plain English: we pretend every team also had 20 extra starts at the field-average retirement rate, so a small sample can't produce an extreme estimate. The field rate, 18.3%, matches the book's reliability table. Aston Martin's raw rate is 21 DNFs in 42 starts (50.0%), and the shrunk rate is 39.8%. RB's raw 7.3% becomes 10.9%.

🧪 Illustrative model: the prior weight of 20 starts, the assumption that DNFs are independent of finishing order, and the assumption that strengths stay fixed over the last two races are modelling choices, not measured facts. Change them in 06_championship_sim.py and the probabilities below move by a few points. Exercise C7 asks you to measure how much.

The simulation

Each simulated race draws DNFs first. Then it orders the finishers by $\theta_i + G_i$, where $G_i$ is independent Gumbel noise, and awards 25-18-15-12-10-8-6-4-2-1. In 2026 there is no fastest-lap point.

🔍 Why this works: if you add independent standard Gumbel noise to each log-strength and sort, the resulting order has exactly the Plackett–Luce distribution. The winner is driver $i$ with probability $e^{\theta_i} / \sum_j e^{\theta_j}$, and the same holds at every later step (the "Gumbel-max trick"). So one vectorised argsort per race simulates 10,000 finishing orders at once, with no loops over positions.

# project/boxbox/predict.py (excerpt): one simulated race for all n_sims runs at once
u = base + rng.gumbel(size=(n_sims, n))                 # log-strength + Gumbel noise
dnf = rng.random((n_sims, n)) < pdnf[None, :]           # retirements first
u[dnf] = -np.inf                                        # retired cars sort last
order = np.argsort(-u, axis=1)
place = np.empty_like(order)
np.put_along_axis(place, order, np.tile(np.arange(n), (n_sims, 1)), axis=1)
gained = table[place]                                   # points by finishing place
gained[dnf] = 0.0

We run 10,000 seasons-to-go twice:

  • with the point strengths;
  • with parameter uncertainty: each simulated season draws its strength vector from the 200 race-bootstrap fits, so a driver whose strength is uncertain gets more spread.
... with parameter uncertainty (strengths drawn from the race bootstrap):
    driver_ref  points_now  mean_final  p_P2  p_P3  p_P4  p_P5  p_P6
     antonelli       402.0     428.470 0.000 0.000 0.000 0.000 0.000
max_verstappen       304.0     334.588 0.991 0.009 0.000 0.000 0.000
      hamilton       267.0     288.209 0.003 0.390 0.331 0.212 0.064
        norris       264.0     287.225 0.004 0.387 0.304 0.217 0.088
       russell       264.0     281.145 0.001 0.171 0.265 0.376 0.186
       leclerc       250.0     270.620 0.000 0.044 0.100 0.195 0.661

Stacked horizontal bars of the simulated probability of each final championship place from P2 to P6 for Verstappen, Hamilton, Russell, Norris and Leclerc after round 21 of 2026; Verstappen is P2 in 99 percent of runs, Hamilton and Norris split P3 at about 39 percent each

📊 Figure (described): Model output at the R21 snapshot, not a record of what happened. Verstappen keeps P2 in 99.1% of runs. Third place is close to a coin toss between Hamilton (39.0%) and Norris (38.7%), with Russell at 17.1% and Leclerc at 4.4%. Leclerc is most likely sixth (66.1%).

Constructors' places after R23 ... with parameter uncertainty:
    team_ref  points_now  mean_final  p_P1  p_P2  p_P3  p_P4  p_P5  p_P6  p_P7
    mercedes       666.0     709.616   1.0   0.0  0.00  0.00 0.000 0.000 0.000
     ferrari       517.0     558.829   0.0   1.0  0.00  0.00 0.000 0.000 0.000
    red_bull       440.0     481.697   0.0   0.0  0.75  0.25 0.000 0.000 0.000
     mclaren       431.0     467.030   0.0   0.0  0.25  0.75 0.000 0.000 0.000
          rb       114.0     127.610   0.0   0.0  0.00  0.00 0.986 0.014 0.000
      alpine        87.0      95.570   0.0   0.0  0.00  0.00 0.014 0.986 0.000
        audi        28.0      37.014   0.0   0.0  0.00  0.00 0.000 0.000 0.570
        haas        31.0      33.993   0.0   0.0  0.00  0.00 0.000 0.000 0.410

Heat map of simulated final constructors' places for the 11 teams after round 21 of 2026; Mercedes P1 and Ferrari P2 at 100 percent, Red Bull P3 75 percent against McLaren 25 percent, RB P5 99 percent, and Audi against Haas for P7 at 57 to 41 percent

📊 Figure (described): Each row is a team (points after R21 in brackets), each column a final place, each cell the share of 10,000 simulations. Mercedes and Ferrari are fixed in the top two: Red Bull could only catch Ferrari's 77-point lead with a perfect weekend while Ferrari scored almost nothing, and no simulation produced that. The live fights are P3, Red Bull against McLaren (75/25), and P7, Audi against Haas (57/41). There Audi's stronger recent finishing orders outweigh Haas's 3-point lead.

Three remarks on reading these outputs.

  1. Parameter uncertainty matters less than you might expect here. Adding it moved Red Bull's P3 probability from 77.7% to 75.0%. With only two races left, race-day randomness (DNFs and the Gumbel noise) dominates uncertainty about the strengths.
  2. The simulation is not the points-per-race extrapolation. Adding twice each driver's R12–R21 average to his current total gives Norris 290 and Hamilton 285, so Norris third. The simulator puts them level (39.0% against 38.7%). The extrapolation uses average points only. The simulation uses the whole distribution of finishing orders, Hamilton's 3-point head start and each team's DNF rate.
  3. It is a model output at the snapshot. The book's data end at the 2026 Las Vegas GP. Whatever happened in Qatar and Abu Dhabi, these probabilities are what the model said with 21 rounds of evidence. Case study 2 tests how such statements held up in 2014–2025.

📋 Try it — Call the pit stop: 2026 Italian GP, end of lap 28 of 53. A VSC has just been deployed. You are on Antonelli's pit wall. He is P2, 0.281 s behind Russell. Both cars are on tyres 24 laps old: Antonelli on MEDIUM, Russell on HARD, both fitted at the red-flag stoppage. The green-flag pit loss at Monza is 25.4 s (median of 76 stops, 2023–2026). Under a VSC the pooled figure is 15.7 s [14.5, 16.8] (n = 106; Chapter 14). Fresh tyres are worth a median 1.08 s/lap in dry races. Box or stay out? Decide before you open the reveal.

What happened (OpenF1)

Antonelli and Verstappen boxed under the VSC (pit-lane times 25.0 s and 24.9 s) for fresh MEDIUM and HARD tyres respectively. Russell stayed out on his hards and ran them to the flag, 49 laps old at the finish. At the end of lap 29 Antonelli was P6, 14.3 s behind Russell. His first green lap on new tyres was 84.595 s against Russell's 85.660, and the gap came down from 14.3 s (lap 29) to 7.1 s (lap 40), about 0.66 s per lap. He was back to P2 by lap 37, led from the end of lap 50 and won. The arithmetic of the call: about 14 s of track position spent (VSC pit loss) to buy roughly 25 laps × 0.6–1.1 s/lap, i.e. 15–27 s, of tyre advantage. The stop was favourable as long as passing Russell was possible. At Monza it was. No pre-race forecast could have contained this decision, because the VSC didn't exist yet.

🔄 Check your understanding 1. Why does the simulator draw DNFs before sorting by strength, instead of letting a retirement be "a very low finishing place"? 2. Mercedes' 666 against Ferrari's 517 is a "settled" title. Ferrari's 517 against Red Bull's 440 is a 77-point gap with 86 available, yet the simulator gives Ferrari 100%. Is that the same kind of certainty?

Answer

  1. Retirements are not driven by pace: a fast car can break down as easily as a slow one, and the Plackett–Luce strengths were fitted on finishing orders without retirements. Modelling DNF separately keeps the two processes apart. A retired car also scores zero points regardless of where it "would" have finished.
  2. No. Mercedes' title is arithmetic: no outcome changes it. Ferrari's P2 is a probability that rounds to 100%. Red Bull would need a 1-2 in both races (86 points) while Ferrari scored no more than 9 in total. That is possible in principle, but it did not occur in 10,000 runs. "Never seen in simulation" means "below about 1 in 10,000 under this model", which is not the same as impossible.

26.9 What the models cannot see

Every forecast in this chapter is made before the race. The race itself contains events that no pre-race feature can carry. That is the size of the gap between Section 26.6's 55% and the 100% we would like.

Neutralisations and red flags. In 2023–2026, 72.5% of Grands Prix had at least one SC, VSC or red flag (Chapter 14). They reshuffle strategy, as the Monza call showed. Do they explain upsets? code/case_study_01.py lists the 10 winners in 2023–2026 to whom the boosting model gave less than 10% before the race:

2023-2026 winners (91 GPs): 10 had a pre-race boosting p_win < 10%:
 year                     race winner  grid  p_win  neutralised   red
 2025         Miami Grand Prix    PIA   4.0  0.027         True False
 2024 United States Grand Prix    LEC   4.0  0.027         True False
 2026       Italian Grand Prix    ANT  19.0  0.029         True  True
 2024         Miami Grand Prix    NOR   5.0  0.049         True False
 2024       Belgian Grand Prix    HAM   3.0  0.055        False False
 2024       Italian Grand Prix    LEC   4.0  0.058        False False
 2024     São Paulo Grand Prix    VER  17.0  0.069         True  True
 2024      Austrian Grand Prix    RUS   3.0  0.071         True False
 2025       British Grand Prix    NOR   3.0  0.078         True False
 2023    Azerbaijan Grand Prix    PER   3.0  0.083         True False
  races with an SC/VSC/red flag, winner p_win < 10%: 8/10 = 80% (49-94)
  races with an SC/VSC/red flag, winner p_win >= 10%: 58/81 = 72% (61-80)

Eight of the ten long-shot wins came in neutralised races. So did 72% of the expected wins. With ten upsets, the data can't separate "neutralisations cause upsets" from "most races are neutralised anyway". The two intervals overlap almost completely. Two of the long shots (2024 Belgium and 2024 Monza) came in races with no neutralisation at all: there, something else (pace on the day, or strategy) made the difference. The honest conclusion is that upsets come from many sources, and neutralisations are only one of them. Chapter 27's Monte Carlo engine simulates them explicitly instead of hoping the features catch them.

Other blind spots, each visible in our data:

  • Penalties after qualifying. Antonelli qualified 7th at Monza and started 19th; he qualified fastest at Las Vegas and started 6th. The race model sees the actual grid, but a Thursday forecast cannot know about penalties to come.
  • Reliability. 18.3% of 2026 starters did not finish (83 of 453). Our models carry a trailing DNF-rate feature, and its permutation importance is 0.001. A retirement is close to unforecastable for a given driver on a given Sunday.
  • Rule changes. Section 26.3 showed the trailing features fail at round 1 of a new formula. The 2026 pre-qualifying model's 19% is the cost.
  • Line-up changes. Three drivers with 2026 points were not in the R21 entry list, and the 2026 Red Bull and RB line-ups changed during the season (Chapter 21). Driver-level form features reset with each change.
  • What teams decide. Team orders, tyre choices and strategy calls are not in the features. The data can show what happened, never what was intended.
  • The market. Bookmakers' prices would be the toughest benchmark of all, but they are not part of the book's free data. Chapter 38 teaches the method on clearly labelled hypothetical odds.

🔄 Check your understanding 1. Ray says: "Your model and the pole-sitter pick are tied at 55%. Why bother?" Give two concrete reasons, one for a bettor and one for a strategist. 2. Suppose a 2027 model adds "the number of SC deployments at this circuit in 2023–2026" as a feature. Is that a leak? Will it help?

Answer

  1. Bettor: the model's probabilities are better calibrated than the grid table (log loss 0.135 better, with an interval excluding 0), and pricing depends on probabilities, not picks. Strategist: the race simulator (Chapter 27) needs a per-driver pace and finishing distribution for every car, not just a winner. The models give that; the pole pick does not.
  2. Not a leak, as long as only earlier seasons are counted. It may help a little for P(podium) of long shots, but per race the SC is close to a coin flip (48.4% of 2023–26 races had one), so its effect on the favourite's win probability is small. Test it walk-forward before believing it.

Spaced Review

Three ideas from earlier chapters carry this one. Try each question before reading the reminder.

From Chapter 21 — what did K = 32 mean, and why was it chosen? Chapter 21 rated drivers by Elo on teammate qualifying duels. K is the step size of each update. It was chosen by log loss on duels from 2006 on: K = 32 scored 0.6176, against 0.6931 for a coin flip, and the favourite won 66.1% of duels. That same log-loss logic chose our Plackett–Luce half-life in Section 26.8. It is one idea, used twice: pick tuning constants by scoring honest out-of-sample predictions. The Elo used here is the pre-duel rating, because the post-duel rating would leak the round's own result.

From Chapter 17 — how often does the pole-sitter lead at the end of lap 1, and how much of a lap-1 gain survives to the flag? In Chapter 17, the pole-sitter led lap 1 in 74.3% of races (430 of 579, 1996–2026). Each place gained on lap 1 was associated with only 0.43 places at the finish. Put those beside Section 26.2: pole wins about 52–56%, so roughly a quarter of the pole's advantage is lost at the start and much of the rest during the race. A race model starts from the grid and has to learn that discount from data.

From Chapter 14 — what share of 2023–26 races had a full safety car, and why does that matter for a forecast? Chapter 14 found an SC in 48.4% of 2023–2026 races, and an SC, VSC or red flag in 72.5%. The per-lap SC hazard was 0.0115, with lap 1 about nine times riskier. That base rate explains why Section 26.9 could not tie upsets to neutralisations: when three races in four have one, "the upset race had a VSC" is the normal case, not the exception.


Project Checkpoint: predict.py

Aisha's message to the group the week after Las Vegas was short: "The simulator now knows who's fast. Next it has to know who's lucky." This chapter gives Box Box its forecasting layer. project/boxbox/predict.py exposes:

function what it does
build_features(years=(2006, 2026), elo_k=32) one row per driver per GP; pre-race features (shifted rolling windows, pre-duel Elo, trailing team gaps) and targets (win, podium, finishing band)
train(df, model, features) fits "logit", "ordinal", "rf" or "gbm" win and podium models
predict_race(fitted, df_race) per-driver p_win (sums to 1), p_podium (sums to 3), pred_rank
walk_forward(df, model, features, test_years) time-respecting validation: train on seasons < Y, predict Y
baselines(df, test_years) grid-slot-history probabilities from training seasons only
score(pred) / reliability(pred) top-1, podium hit rate, Brier, log loss; calibration table
standings_after(year, rnd) drivers' and constructors' standings from GP + sprint results
is_dnf(results) / is_starter(results) the correct finish flags (not is_classified)
fit_strengths(results, half_life=10) recency-weighted Plackett–Luce log-strengths
simulate_championship(drivers, strengths, p_dnf, n_races, ...) Gumbel-trick season simulation; driver and constructor place probabilities; per-event points tables (sprints, double points)

The module imports boxbox.ratings (Chapter 21) for the cleaned qualifying table and the Elo duels, and boxbox.development (Chapter 24) for team lineages and circuit types. code/project_checkpoint.py runs the whole chain on real data in about 20 seconds:

from boxbox import predict
feats = predict.build_features((2006, 2026))
fit = predict.train(feats[feats.year <= 2025], model="gbm", features=predict.FEATURES_RACE)
lv = predict.predict_race(fit, feats[(feats.year == 2026) & (feats["round"] == 21)])
d, c = predict.standings_after(2026, 21)
th = predict.fit_strengths(history.results(2026), half_life=10)
sim = predict.simulate_championship(dd, th, p_dnf, n_races=2, n_sims=4000, seed=42,
                                    constructors=c[["team_ref", "points", "wins"]])
predict_race: 2026 Las Vegas GP (model trained on 2006-2025 only)
abbreviation team_ref  grid  quali_pos  p_win  p_podium  pred_rank  pos
         VER red_bull   1.0        2.0  0.659     0.809        1.0  1.0
         ANT mercedes   6.0        1.0  0.136     0.381        2.0  4.0
         NOR  mclaren   3.0        4.0  0.095     0.479        3.0  2.0
score: favourite won = True, podium names hit = 0.67, Brier = 0.149, -ln p(winner) = 0.416

simulate_championship: R22-R23, 4,000 runs, common DNF probability 0.183 per car per race
    driver_ref  points_now  mean_final  p_P1  p_P2  p_P3
max_verstappen       304.0     334.155   0.0 0.988 0.012
      hamilton       267.0     287.486   0.0 0.004 0.384
        norris       264.0     286.477   0.0 0.006 0.370
team_ref  points_now  mean_final  p_P1  p_P2  p_P3  p_P4
red_bull       440.0     481.822   0.0   0.0 0.775 0.225
 mclaren       431.0     465.502   0.0   0.0 0.225 0.775

The checkpoint uses one common DNF probability for every car. That is a deliberate simplification of the per-team version in 06_championship_sim.py, and the outputs differ by a point or two: compare Red Bull's 77.5% here with 75.0% there.

How it plugs in later.

  • Chapter 27's Monte Carlo race engine needs a per-car pace and a finishing-order model for traffic and DNFs. fit_strengths and is_dnf give it the season-level version.
  • Chapter 38 turns p_win into prices and tests "edges". It needs reliability() first, because an edge built on a miscalibrated probability is an illusion.
  • Chapter 40 wires predict_race into python -m boxbox simulate as the pre-race prior.

Chapter Summary

Metrics and models

quantity formula / definition value in this chapter
Top-1 accuracy share of races the favourite won models 0.542–0.582 (2014–26); pole pick 0.557
Podium hit rate share of 3 podium names correct models 0.680–0.683; grid top 3 0.687
Brier score (race) $\sum_i (p_i - y_i)^2$ grid baseline 0.637; boosting 0.605; logistic 0.602
Winner log loss $-\ln p_{\text{winner}}$ grid 1.439; boosting 1.304; random forest 1.275
Pole → win (baseline) Jolpica, Wilson 51.6% (1994–26), 55.7% (2014–26), 62.6% (2023–26)
Leader → win (baseline) leader before the race 42.7% (2014–26), 35.0% (2026)
Pre-qualifying model no grid or qualifying features top-1 0.440–0.473; −11.7 points vs pole [−19.4, −4.0]
Qualifying forecast, pole 2023–26, blend of model and practice 39/90 (43.3%); practice alone 36/89
Plackett–Luce $P(\text{order}) = \prod_k e^{\theta_k}/\sum_{j\ge k} e^{\theta_j}$ half-life 10 races; +5.30 nats per race over chance
Shrunk DNF rate $(\text{DNF} + 20\bar p)/(\text{starts} + 20)$ field 18.3% (83/453, 2026)
2026 after R21 (model output) 10,000 simulations of R22–R23 VER P2 99.1%; P3 HAM 39.0% / NOR 38.7%; Red Bull P3 75.0%

Decision checklist for anyone publishing an F1 forecast

  1. Print the baselines first: pole, grid-slot history, leader, grid top 3.
  2. Validate walk-forward. Never let a later race touch a training fold or a feature.
  3. Report Brier and log loss, not only top-1. Use a paired bootstrap for differences.
  4. Draw the reliability diagram. Fix the calibration before you trust any probability above 0.6.
  5. Check every "finished" flag: classified is not the same as finished.
  6. Label simulation outputs as model outputs at a snapshot, with the assumptions (🧪) next to them.
  7. Say what the model cannot see: neutralisations, penalties, weather, reliability, decisions.

What's Next

A race forecast says who is likely to finish where. It does not say why, and it cannot test a strategy. In Chapter 27 we go inside the race: lap by lap, with safety cars, weather, retirements and lap-1 shuffles drawn at random. Thousands of simulated races then let us ask which strategy has the best expected result rather than the best clean-race time. The strengths and DNF model built here become that engine's priors.