Racing Ahead: AI Analysis
Why use AI to analyse numeric data?
AI enables faster, more efficient, and more detailed numeric analysis by automating calculations and pattern recognition that would otherwise require significant manual effort. It can process large datasets consistently and quickly, uncover trends that may be difficult to spot by eye, and generate clear, explainable insights. This allows analysts and decision-makers to focus on interpretation and action rather than time-consuming data preparation.
How does it work?
Numeric data is first pre-processed into a clean, structured format, such as a single table aligning different timings with their corresponding speeds. The dataset is then converted into markdown and included directly in a prompt sent to the Gemini API. This allows the AI to read the data as structured context, perform detailed analysis, and return insights, comparisons, and summaries automatically.
Get the qualifying information
# Step 1: Create unified table
all_times = pd.Series(dtype=float)
for driver, df in lap_times.items():
all_times = pd.concat([all_times, df['Time']])
comparison_df = pd.DataFrame({'Time': all_times.unique()})
comparison_df = comparison_df.sort_values('Time').reset_index(drop=True)
# Step 2: Merge each driver's Speed dynamically
for driver, df in lap_times.items():
comparison_df = pd.merge(
comparison_df,
df[['Time', 'Speed']],
on='Time',
how='outer'
).rename(columns={'Speed': f'{driver} Speed'})
comparison_df
Sense check the output
Make API Call
The API key was stored locally for the purpose of this project as this would not be pushed to production. In a production environment, this API key would be stored in a password manager like Azure Key Vault
client = genai.Client(api_key=API_KEY)
response = client.models.generate_content(
model="gemini-2.5-flash",
contents=f"Here is some data:\n{comparison_df_data}\n\nPlease analyse this dataset, focusing on braking styles and comparitive analysis. These are the qualifying speed traces for drivers around the same track. The speed units are kmph"
)
ai_analysis = response.text
Analysis of the Dataset: Braking and Comparative Analysis
Below is the formatted AI generated reponse
This dataset provides speed traces for three drivers (NOR, PIA, VER) around the same track during qualifying, with speed measured in kmph. The key characteristic of the data is its asynchronous nature: each row generally contains a speed reading for only one driver at a specific timestamp, with nan values for the other drivers. This means we are observing discrete events rather than continuous, synchronized streams.
Let's analyze the braking styles and conduct a comparative analysis.
Overall Observations:
- Lap Structure: The speed traces show clear patterns of acceleration (speeds rising to 320-340 kmph) followed by significant braking events (speeds dropping to 70-100 kmph), indicating a typical lap profile with straights and corners. The data covers approximately 1 minute and 18 seconds of track time.
- Peak Speeds: All three drivers achieve very similar peak speeds, typically in the range of 330-340 kmph. This suggests they are maxing out the car's speed on the straights.
- Variability: While peak speeds are similar, the differences in braking and cornering phases will reveal their distinct styles and relative performance.
Braking Style Analysis - Key Braking Zones:
To understand braking styles, we'll look at the most significant speed drops. There appear to be three major braking events in this recorded segment:
- Braking Zone 1: Approximately 8 to 14 seconds (initial high speed to low speed)
- Braking Zone 2: Approximately 53 to 58 seconds (mid-segment braking)
- Braking Zone 3: Approximately 1 minute 9 seconds to 1 minute 13 seconds (final braking event)
Let's break down each driver's apparent style:
1. VER (VER Speed):
- Braking Point: VER consistently appears to be among the earliest, if not the earliest, to initiate significant braking, or at least shows the first sharp drop in speed when entering a braking zone. For example, in the first major braking zone (around 8.0 seconds, from 348 kmph).
- Braking Intensity/Force: VER seems to brake the hardest, achieving the steepest initial deceleration.
- Zone 1 (0:00:08 - 0:00:10.978): From 348 kmph (at 8.018s) down to 90 kmph (at 10.978s). This is a drop of 258 kmph in ~2.9 seconds, averaging a deceleration of ~89 kmph/s. He hits the lowest minimum speed of all three in this section (73 kmph at 12.979s).
- Zone 2 (0:00:53.898 - 0:00:55.538): From 340 kmph (at 53.898s) down to 195 kmph (at 55.538s). A drop of 145 kmph in ~1.6 seconds, averaging ~91 kmph/s. Again, lowest minimum speed.
- Zone 3 (0:01:09.257 - 0:01:10.897): From 291 kmph (at 1:09.257s) down to 217 kmph (at 1:10.897s). A drop of 74 kmph in ~1.6 seconds, averaging ~46 kmph/s. (Note: He starts this zone at a lower speed than PIA).
- Minimum Speed: Often reaches the lowest minimum speed within a braking zone, suggesting aggressive trail braking or a tighter line through the corner.
- Acceleration: Post-braking, VER shows good re-acceleration, quickly picking up speed from his low point.
2. PIA (PIA Speed):
- Braking Point: PIA's braking initiation is generally very close to NOR's, sometimes slightly later than VER.
- Braking Intensity/Force: PIA exhibits strong braking, though perhaps marginally less aggressive than VER's initial bite.
- Zone 1 (0:00:08.150 - 0:00:11.470): From 344 kmph (at 8.150s) down to 83 kmph (at 11.470s). A drop of 261 kmph in ~3.3 seconds, averaging ~79 kmph/s. His minimum speed in this section is 74 kmph (at 13.350s).
- Zone 2 (0:00:54.110 - 0:00:55.471): From 334 kmph (at 54.110s) down to 212 kmph (at 55.471s). A drop of 122 kmph in ~1.3 seconds, averaging ~94 kmph/s. This is a very sharp deceleration, comparable to or even slightly faster than VER's in this specific segment.
- Zone 3 (0:01:09.071 - 0:01:10.829): From 330 kmph (at 1:09.071s) down to 221 kmph (at 1:10.829s). A drop of 109 kmph in ~1.7 seconds, averaging ~64 kmph/s.
- Minimum Speed: Generally slightly higher than VER's, but consistently lower than or equal to NOR's.
- Acceleration: Accelerates well out of corners, showing a good recovery from the braking phase.
3. NOR (NOR Speed):
- Braking Point: NOR's braking points are often similar to PIA's, sometimes appearing to initiate braking slightly later than VER.
- Braking Intensity/Force: NOR's initial braking appears slightly less sharp than VER's in some instances, and comparable to PIA's.
- Zone 1 (0:00:08.047 - 0:00:11.606): From 343 kmph (at 8.047s) down to 84 kmph (at 11.606s). A drop of 259 kmph in ~3.5 seconds, averaging ~74 kmph/s. His minimum speed is 74 kmph (at 12.807s), same as PIA in this section.
- Zone 2 (0:00:54.047 - 0:00:55.767): From 324 kmph (at 54.047s) down to 202 kmph (at 55.767s). A drop of 122 kmph in ~1.7 seconds, averaging ~72 kmph/s. This is less aggressive than VER or PIA in this zone.
- Zone 3 (0:01:09.047 - 0:01:10.966): From 321 kmph (at 1:09.047s) down to 217 kmph (at 1:10.966s). A drop of 104 kmph in ~1.9 seconds, averaging ~55 kmph/s.
- Minimum Speed: Tends to maintain slightly higher minimum speeds through corners compared to VER, and often similar to PIA.
- Acceleration: Shows good acceleration out of corners, but the earlier, harder braking of VER might give him a slight edge in exit speed or setup for the next straight.
Comparative Analysis:
- Aggressiveness: VER appears to be the most aggressive braker, consistently entering braking zones hard and reaching the lowest minimum speeds. This suggests a driving style that optimizes for a sharp turn-in and potentially a later apex to maximize exit speed.
- Consistency: PIA and NOR show somewhat similar patterns in braking zones, though PIA sometimes demonstrates very sharp initial deceleration in certain corners, comparable to VER. NOR seems to be slightly less aggressive in braking, resulting in marginally higher minimum speeds in some sections.
- Overall Performance Implication:
- VER's aggressive braking could be advantageous for lap time if he can consistently carry higher speed through the apex and maintain strong acceleration out of the corner. However, this style also carries higher risk of lock-ups or overdriving.
- PIA's performance seems to be a strong contender, demonstrating bursts of very effective braking.
- NOR's style, while not as outwardly aggressive in braking as VER's, is still effective. The slightly higher minimum speeds might imply a smoother, more flowing approach, which can be beneficial for tire preservation over a race distance, but might sacrifice a fraction of qualifying pace.
Limitations:
- Sparse Data: The asynchronous nature and gaps in the data for each driver make precise, millisecond-by-millisecond comparisons challenging without interpolation. We are inferring trends from discrete points.
- No Track Context: Without a track map or knowledge of corner types, it's hard to definitively say why a driver brakes a certain way (e.g., tight hairpin vs. long sweeping corner).
- Single Lap: This is only a segment of a qualifying lap. A full lap or multiple laps would provide more robust patterns.
Conclusion:
The analysis suggests a distinct difference in braking philosophies:
- VER: Appears to be an "aggressive attacker" under braking, maximizing deceleration and achieving the lowest speeds through corners.
- PIA: Demonstrates strong and sometimes very sharp braking, positioning him as a close rival to VER's aggression.
- NOR: Shows a slightly less aggressive, possibly smoother, braking style that might result in slightly higher minimum corner speeds but potentially better stability or tire management.
In a qualifying scenario, VER's aggressive style might yield marginal gains in lap time due to later braking and harder deceleration, assuming he can maintain control and quickly get back on the power.