Problem
I set out to predict Formula 1 lap-time variation from weather, tire strategy and driver-behavior data (2018 to 2024). Every model scored R² between 0.996 and 0.9998. Sports data is never that predictable, so instead of reporting the score I audited the data.
Approach
The audit. I fit simple least-squares formulas between columns. Each engineered column turned out to be an exact formula (R² = 1.0):
Lap Time Variationis just 0.000329 × average pit-stop time − 0.00545.Driver Aggression Scoreis built partly from the target itself.Fast Lap AttemptsandPosition Changesare rescaled pit time and finishing position.

Removing the leaks one at a time showed where the score came from. With leaky features, test R² was 0.995 on a random split and 0.991 even on a race-grouped split. With them removed it fell to −0.70.
The rebuild. I changed the question to one the data can answer: how well can a driver’s pit-lane time be predicted for a race the model has never seen?
- One row per driver per race, instead of duplicated stint rows
- 25 held-out test races, and
GroupKFoldso tuning folds are grouped by race too - All preprocessing inside scikit-learn
Pipelines, and a mean baseline for every model - Red-flag races handled separately: about 10% of driver-races log 200 to 3,000 s of “pit time” because a race stoppage was counted as pit time
Result
XGBoost reached 2.04 s MAE on unseen races vs 3.73 s for the baseline, 45% lower error (test R² 0.51).

The circuit drives pit time. Shuffling Circuit raises MAE by about 1.8 to 2.0 s, and no other feature comes close, because pit-lane length and speed limit are set by the circuit.

What I’d do next
- Use lap-level data (for example from the FastF1 library) to study real lap-time consistency, which was the original goal.
- Separate time in the pit lane from time stationary in the box. This dataset mixes them.
- Check the result against more seasons, since test scores move noticeably with which races are held out.