Inspiration In Formula 1, track safety is a fundamentally reactive process. Race Control relies on trackside marshals waving flags and humans monitoring dozens of camera feeds to spot a crash and neutralize the race. This human bottleneck costs crucial seconds—or sometimes over a minute—leaving drivers fully exposed to high-speed, secondary collisions. We realized that modern F1 cars generate gigabytes of telemetry per race, and we wanted to use that data to build a proactive, machine-learning early warning system. We wanted to build a digital Race Director.

What it does ApexGuard is an AI-powered Safety Car prediction engine. Instead of waiting for human visual confirmation of a crash, it monitors the entire 20-car grid simultaneously. By aggregating real-time mechanical telemetry (like speed trap anomalies and pace drops) and environmental context (weather deviations, tire degradation, and track abrasion), it detects the exact mathematical signature of a crash as it happens. It then generates a live "Danger Index," instantly predicting a track-wide Safety Car deployment before the official flags are even waved.

How we built it We built the core pipeline using Python, Pandas, and Scikit-Learn.

Data Sourcing: We used the FastF1 API to pull massive historical datasets from the 2019 and 2021 F1 seasons, including lap times, weather sensors, and official race control messages.

Feature Engineering: We calculated rolling pace averages, mapped official Pirelli asphalt abrasion scores, and created "deviation" metrics (e.g., how much the current track temp differs from the race baseline). Most importantly, we engineered Speed_Anomaly_Delta—a lightweight proxy metric that calculates how far a driver's speed trap reading plummeted compared to their own normal top speed.

Machine Learning: We trained a RandomForestClassifier. To prove it works in the real world, we didn't just randomly split the data. We split the data by race, training the AI on a mix of dry/wet tracks and testing it on completely unseen, notoriously chaotic races (like the wet 2020 Turkish GP).

Challenges we ran into The "Time Travel" Data Leakage Trap: Initially, our model had a 99% accuracy because it was looking at lap times after the safety car was already out. We had to rethink our pipeline, shifting the target and using Previous_LapTimeDelta to ensure the AI acted as a true early warning system.

The 19 Normal Drivers Problem: A crash is a local anomaly that causes a global event. 19 drivers could be driving perfectly normally while one driver crashes, confusing the model. We solved this by engineering Track-Wide Aggregations (Trackwide_Max_Speed_Anomaly), teaching the AI to scan the whole grid and trigger a global alert if any single car registered a massive speed drop.

Pandas Bottlenecks: Our initial data loop using .iloc took over 20 minutes to process a few races. We had to completely refactor our feature building using vectorized Pandas operations and .dt.total_seconds(), cutting processing time down to seconds.

Accomplishments that we're proud of We are incredibly proud of shattering the ROC-AUC ceiling on unseen data. It is mathematically difficult to predict rare events like crashes. By properly tuning our class_weight, implementing dynamic percentile thresholding, and adding the micro-sector speed trap anomalies, we proved that our Random Forest didn't just memorize tracks—it genuinely learned the mechanical physics of a loss-of-control event.

What we learned Domain knowledge is just as important as math: Feeding the model raw numbers didn't work until we applied real F1 context (like manually mapping Pirelli's track abrasion scores).

How you test is everything: We learned the hard way about Covariate Shift. When we trained only on dry races, the model failed on wet ones. We learned how to properly structure train/test splits to ensure our AI generalizes to new environments.

Probabilities need UI: We learned that raw model probabilities (e.g., "30% chance of crash") are useless to a race engineer. We learned how to scale those outputs into a dynamic, color-coded UI "Danger Index" that a human can actually make split-second decisions with.

What's next for ApexGuard Live SignalR Integration: Hooking our ingestion pipeline directly into FastF1's Live Timing Client to process telemetry in true real-time during a live Grand Prix weekend.

Smart Vision Routing: We originally explored using YOLO computer vision, but running heavy vision AI on 20 cars simultaneously is too computationally expensive. Next, we want to combine them: ApexGuard's lightweight telemetry AI will act as the "trigger," instantly routing the heavy YOLO vision model only to the specific camera feed of the car that registered the telemetry anomaly.

VSC vs. SC Classification: Upgrading our binary classifier into a multi-class model to predict whether an incident warrants a Virtual Safety Car, a Full Safety Car, or a Red Flag.

Built With

Share this project:

Updates

Submission history