All work

Simulation & Statistical Modelling

Complete

F1 Strategy Simulation & Decision Framework

Which pit-stop strategy wins a Grand Prix — and can a model show it before the race?

Role
Sole developer
Timeline
Oct–Dec 2025
Category
Simulation & Statistical Modelling
Stakeholder
Personal project
Historical race laps modelled
86,000+Historical race laps modelledFastF1 data across 74 races, 2022–2024.
Lap-time mean absolute error
2.6sLap-time mean absolute errorXGBoost regressor (R² 0.441); tire compound is the dominant feature (46.1%).
Abu Dhabi 2024 validation
P2Abu Dhabi 2024 validationCorrectly predicted Norris’s optimal 1-stop over a 2-stop across a 58-lap simulation.
  • XGBoost
  • Python
  • Flask
  • React
  • Docker

In 30 seconds

An XGBoost-driven race simulator that compares alternative pit strategies across a full Grand Prix, validated against the Abu Dhabi 2024 result.

Historical race laps modelled
86,000+Historical race laps modelled
Lap-time mean absolute error
2.6sLap-time mean absolute error
Abu Dhabi 2024 validation
P2Abu Dhabi 2024 validation

Context

Pit-stop strategy is one of the highest-leverage decisions in a Grand Prix, and it is fundamentally a comparison problem: given the current race state, does strategy A or strategy B finish ahead?

This project builds a simulator to answer that before the race — predicting lap times under different tire plans and running a full-race simulation for all 20 drivers, then comparing the outcomes.

It is a personal project, framed for an F1 strategist as the notional user; the value is the decision framework, not a claim of production race use.

Data

Source
FastF1 API (official F1 timing data)
Time period
2022–2024 seasons
Records
86,000+ laps across 74 races
Granularity
Per-lap, with 71 engineered features

Data quality & handling

  • Restricted to features known before each lap (tire state, race context, environment) — outcome features like average speed were removed to avoid circular reasoning.
  • 95% data completeness after cleaning.
  • Temporal train/test split (80/20) so the model is evaluated on unseen later data.

Data dictionary

TableDescriptionSize
TyreLife / CompoundTire age and compound — the dominant predictors.feature
LapNumber / Position / GapToAheadRace context.feature
TrackTemp / AirTempEnvironmental conditions.feature

Analytical approach

The simulation engine is deliberately modular — driver state, lap-time prediction, race simulation, and the high-level strategy interface are separate components, which keeps it testable.

  1. Extract laps (FastF1)
  2. Engineer 71 features
  3. Train XGBoost lap-time model
  4. Simulate full race (20 drivers)
  5. Compare strategies
  6. Serve via Flask API + React

Findings

Tire compound dominates lap-time prediction.

Tire compound accounts for 46.1% of the lap-time model’s feature importance — far more than any other input.

Why it matters. The model learned real F1 strategy principles rather than spurious correlations, which is what makes its strategy comparisons trustworthy.

XGBoost beat an LSTM by more than 2x on error.

A gradient-boosted model reached 2.6s mean absolute error versus 6.0s for an LSTM on the same data.

Why it matters. With ~64k tabular laps and strong feature relationships, tree models fit better than deep sequence models — picking the right tool matters more than picking the fanciest one.

Caveat. The comparison is specific to this dataset size and feature structure.

The model matched a real race outcome.

For Abu Dhabi 2024, it preferred Norris’s one-stop over a two-stop alternative across a full 58-lap simulation — the strategy McLaren actually ran to finish P2.

Why it matters. A backtest against a known result is the most direct check that the simulator’s relative comparisons are sound.

Caveat. A single validated race is encouraging, not conclusive.

Across 164 replayed stints, finishing position landed within one place half the time.

A validation harness replayed 164 scenarios across 22 races of the 2024 season. Finishing position was exact in 28% of runs and within one place in 51%. Median lap-time error was 2.31s, though the mean is 5.09s — a small number of runs degrade badly, and the distribution is skewed rather than uniformly accurate.

Why it matters. Reporting the median next to the mean is the honest version: the model is good in the typical case and occasionally poor, and a single headline error figure would hide that.

Caveat. These runs replay the actual pit laps rather than choosing them, so they measure race-simulation fidelity, not strategy-selection accuracy. The 100% “strategy match” in the output file is a consequence of that design, not a prediction result.

Validation

  • Model selection

    XGBoost was benchmarked against an LSTM and won decisively (2.6s vs 6.0s MAE), consistent with tabular data and a moderate sample size favouring tree models.

  • Real-race backtest

    Against Abu Dhabi 2024, the model preferred the one-stop that McLaren actually ran for Norris to finish P2.

  • Systematic replay harness (164 scenarios)

    A validation suite replayed 164 stint scenarios across 22 races of the 2024 season, recording position error and lap-time error per run. Finishing position was exact in 28% of runs and within one place in 51%; median lap-time error was 2.31s against a mean of 5.09s. Because the harness replays actual pit laps rather than selecting them, it measures simulation fidelity rather than strategy-selection accuracy.

  • Leakage-free features

    Only pre-lap information is used, so predictions cannot borrow from the outcome they are meant to predict.

Limitations

  • A 2.6s absolute lap-time error is meaningful; the tool is designed for relative strategy comparison, where both options share the same model bias.
  • The lap-time model’s R² is 0.441 — it captures the dominant drivers of pace, not every nuance.

Technical appendix

Models

Lap-time predictor: XGBoost regressor, MAE 2.587s, R² 0.441, tire compound at 46.1% feature importance. A separate pit-stop classifier reached F1 = 0.80 on 64,237 laps.

Deployment

Dockerized Flask REST API on Railway, React (Vite + Tailwind) frontend on Vercel, releases automated via GitHub Actions CI/CD.