Skip to content

anany-afk/FormulaOne

Repository files navigation

🏎️ F1 Telemetry Intelligence System

A machine learning–driven Formula 1 telemetry analysis platform that breaks down driver performance at a segment level — using braking zones, throttle traces, and speed data to reveal exactly where time is lost and won on track.

Consistency Dashboard


🚀 Features

🔬 Telemetry Analysis

  • Pulls real session data via the FastF1 API with local caching
  • Supports any circuit, season, and session type (Race, Qualifying, Practice)
  • Configurable driver comparison — just change three lines

🧩 Intelligent Track Segmentation

  • Automatically detects braking zones as natural segment boundaries
  • Filters out micro-segments with too few data points
  • Each segment becomes one row of ML-ready features

🤖 Machine Learning

  • Random Forest Classifier predicts the faster driver per track segment
  • Trained on all quick laps — not just a single lap
  • Features engineered from raw telemetry: speed, throttle, brake ratio, segment length

📊 Advanced Visualizations

Visualization What it shows
Braking Zone Map Where each driver initiates braking on track
Speed Heatmap Racing line colored by speed — red = slow, green = fast
Time Loss Map Exactly where on track each driver gains or loses time
Braking Distance Markers Who brakes later, and by how many metres, at each corner
Synchronized Telemetry Speed + throttle + brake traces overlaid, aligned by distance
Corner Cards Per-corner breakdown: braking point, min speed, exit throttle
Consistency Dashboard Lap-over-lap variation across all quick laps with tire deg correction

🧠 How It Works

FastF1 API
    │
    ▼
Session Load (Race / Qualifying / Practice)
    │
    ▼
Lap Filtering (pick_quicklaps)
    │
    ├──► Segmentation by Braking Zones
    │         │
    │         ▼
    │    Feature Extraction per Segment
    │         │
    │         ▼
    │    Random Forest Classifier
    │         │
    │         ▼
    │    Model Verdict + Visualizations
    │
    └──► Fastest Lap Telemetry
              │
              ▼
         Speed Heatmap / Time Loss Map /
         Braking Markers / Corner Cards /
         Synchronized Traces

📁 Project Structure

F1-Telemetry/
│
├── F1_main.py            # Entry point — session config, ML pipeline, visualization calls
├── F1_segmentation.py    # Braking zone detection and lap segmentation
├── F1_features.py        # Feature engineering — converts segments to ML rows
├── F1_visualization.py   # All plotting functions
├── F1_telemetry.py       # Standalone qualifying telemetry comparison tool
│
├── segments_dataset.csv  # Auto-generated ML dataset
├── cache/                # FastF1 session cache (auto-created)
└── assets/               # Output screenshots for README

⚙️ Installation

pip install fastf1 pandas matplotlib scikit-learn scipy seaborn

Requires Python 3.9+. FastF1 will auto-download session data on first run and cache it locally.


▶️ Usage

  1. Open F1_main.py and set your session at the top:
circuit      = "Suzuka"
season       = 2025
session_type = "R"       # R = Race, Q = Qualifying, FP1/FP2/FP3

driver1 = "VER"
driver2 = "NOR"
  1. Run:
python F1_main.py

All plots will render sequentially. The dataset is saved automatically as segments_dataset.csv.


📊 Model Details

Features used per segment

Feature Description
avg_speed Mean speed through the segment
min_speed Minimum speed (corner apex proxy)
max_speed Maximum speed through the segment
avg_throttle Mean throttle application
brake_ratio Fraction of segment spent braking
segment_length Distance covered in the segment (metres)

Target

  • Binary: which driver is faster through this segment (0 = driver1, 1 = driver2)

Model

  • RandomForestClassifier — 200 estimators, max depth 6
  • 80/20 train/test split, stratified
  • Evaluated with accuracy score + classification report

📸 Output Examples

Braking Zones

Braking Zones — Driver 1 Braking Zones — Driver 2

Speed Heatmaps

Speed Heatmap — Driver 1 Speed Heatmap — Driver 2

Head-to-Head Analysis

Braking Point Comparison Time Loss Map Synchronized Telemetry

Segment Intelligence

Track Segments Corner Cards

Consistency Report

Consistency Dashboard


🔮 Roadmap

  • Driver Fingerprinting — unsupervised clustering to identify driving style signatures
  • Anomaly Detection — automatically flag unusual laps (lock-ups, traffic, mistakes)
  • SHAP Explainability — show why the model picked a winner per segment
  • Tire Degradation Modelling — predict pace drop-off curves per driver
  • Overtaking Opportunity Heatmap — score each track section for attack likelihood
  • Optimal Lap Reconstruction — simulate a theoretical best lap from race data
  • Web Dashboard — interactive Plotly/Dash interface
  • Multi-driver comparison — extend beyond two drivers

🤝 Contributing

Open to improvements, bug fixes, and feature additions. Feel free to fork and open a PR.


📄 License

MIT

About

ML-powered F1 telemetry analyzer — compares drivers segment-by-segment using braking zones, speed heatmaps, time loss maps, and a consistency dashboard built on FastF1 + Random Forest.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages