Back to work

Case study

F1 Pit Stop Predictor

Predicts Formula 1 pit stop timing from race data with an XGBoost and LSTM ensemble, deployed with a strategy optimizer as an interactive app.

Role
Model development and deployment
Tools
Python, XGBoost, LSTM, Optuna, FastF1, Streamlit
Status
Status: Completed

Key results

ROC-AUC
0.93
XGBoost and LSTM ensemble
Laps of race data
42,500+
19 engineered inputs

Overview

I built a model that predicts pit stop timing from more than 42,500 laps of race data. It uses 19 engineered inputs covering tire and opponent-tire context, circuit pit loss, weather, and race context, and combines an Optuna-tuned XGBoost classifier with a 2-layer LSTM to reach 0.93 ROC-AUC.

I held out a stratified random 20% of laps as the test set and tuned XGBoost with stratified 5-fold cross-validation. The split is by lap, not by race, so laps from the same race can appear in both training and test data. Pit loss is a cross-season mean per circuit: for each race I estimated it from FastF1 lap times as the pit in-lap time minus the driver’s rolling average pace, then averaged those estimates by circuit across seasons. The model is deployed with a strategy optimizer as a Streamlit app. A Monte Carlo, opponent-aware v2 is in progress.

FIG. 1Live app, example input: Abu Dhabi Grand Prix, lap 20 of 57, medium tires 12 laps old. Output shows a 66.1% pit probability against a 0.65 operating threshold.