Streaming Race Engineer

F1 telemetry · causal forecasting · explainable AI

How a lap becomes a live final-time forecast

The model watches a Formula 1 lap unfold from 0% to 100% distance and predicts the final lap time at every point, using only telemetry that would already be known at that position.

400 spatial steps
8 telemetry channels
3 Bahrain seasons
Prediction @ 58% 1:35.842 final lap

The problem

Predict the finish before the lap is finished

At track position p%, the model has only seen the telemetry prefix from the start of the lap to that point. It must forecast the final lap time without looking at future corners, straights, traffic, or sector times.

final_hat(p) = elapsed(p) + remaining_hat(p)

The known elapsed time is added exactly. The neural network only learns the uncertain part: how much time is still left in the lap.

Try the streaming view

Move through the lap

The prediction stabilizes as more of the lap becomes visible. Early estimates depend more on driver, car, tyre and race context; later estimates lean on the actual telemetry trace.

50% Mid-lap forecast
Context share 48%
Telemetry share 52%
Uncertainty ±1.10s

The data

One circuit, three seasons, clean racing laps

EventBahrain GP
Seasons2022-2024
Drivers10
Clean laps1459
Spatial grid400 steps
Telemetry8 channels
Samplingby distance
Validationleave-one-season-out

Telemetry is resampled by distance, not by time. That means 50% always means the same physical place on the track, so laps can be compared point-for-point while the model still receives only the prefix seen so far. Data comes from FastF1.

The pipeline

Four steps, one causal forecast

1

Raw Telemetry

0 to p% of the lap

Speed Throttle Brake RPM Gear DRS Gap ahead Car ahead

Lap context · static

Driver · Team Compound · TyreLife LapNumber · Stint · Position
2

Preprocessing

Same place every lap

0%400 steps100%
Telemetry Scalertrain-fit only
Context Encoderone-hot + numeric vector
3

Causal GRU

Step k reads only 0...k

x1GRUlocked
x2GRUlocked
x3GRUlocked
...
x400GRUlocked
MLPstatic context to baseline pace branch
Gate: remaining goes to 0 at the line
4

Output & XAI

elapsed(p) + remaining

Final Lap Time · seconds refined at every step

Integrated Gradients · seconds

SpdThrBrkRPMGrDRSGapCar

This is the same idea as the Streamlit poster: raw telemetry and static context are aligned, scaled, encoded, streamed through a causal GRU, then decomposed by Integrated Gradients.

What the model sees

Telemetry plus race context

km/h

Speed

The most direct pace signal through every corner and straight.

0-100%

Throttle

How early and how strongly the driver commits to acceleration.

on/off

Brake

Braking points and deceleration patterns into heavy corners.

engine

RPM + Gear

Power-unit load and gear choice alongside the speed trace.

open/closed

DRS

Drag-reduction state on straights where lap time moves quickly.

traffic

Gap ahead

Dirty air and traffic signal from the car physically ahead.

static

Driver + car

Driver identity, team, tyre compound, stint, tyre age and position.

guardrail

No leakage

No sector-time target hints or future telemetry enter the input.

Explainability

Integrated Gradients turns black-box output into seconds

neutral baseline lap this lap prediction - baseline

IG walks from a neutral training-mean lap to the actual lap and accumulates gradients along the way. The result is signed seconds: positive values made the forecast slower, negative values made it faster.

Causality check: attribution after the current cutoff is approximately zero, because the GRU never had access to those future steps.

Research foundations

The four ideas behind the build

Streaming · early prediction IEEE TAI 2020

Approaches and Applications of Early Classification of Time Series

Gupta, Gupta, Biswas, Dutta

Names the project's core problem: predict an incomplete series as early as possible. Our model maps each prefix 0...p to a final-time estimate, scored as error vs % of lap completed, not just a full-lap score.

arxiv.org/abs/2005.02595 →
Context forecasting 2017

DeepAR: Probabilistic Forecasting with Autoregressive Recurrent Networks

Salinas, Flunkert, Gasthaus

One global recurrent model across many related series, conditioned on static covariates. This is the blueprint for our shared GRU plus a separate race-context branch instead of a model per driver.

arxiv.org/abs/1704.04110 →
Gated RNN · GRU EMNLP 2014

Learning Phrase Representations using RNN Encoder-Decoder

Cho, van Merrienboer, Gulcehre, Bahdanau, Bougares, Schwenk, Bengio

Introduces the gated recurrent unit. Our causal, unidirectional GRU uses this cell to summarise the telemetry prefix 0...k, so step k never sees the future.

arxiv.org/abs/1406.1078 →
Attribution · XAI ICML 2017

Axiomatic Attribution for Deep Networks

Sundararajan, Taly, Yan

Defines Integrated Gradients. Its completeness axiom lets us state each input's effect in exact seconds that sum to prediction minus baseline, and verify post-cutoff telemetry gets approximately 0.

arxiv.org/abs/1703.01365 →