Skip to content

An interactive dashboard using Streamlit and Plotly to analyze and compare F1 driver performance, featuring head-to-head stats, stint analysis, and an AI scoring model.

License

Notifications You must be signed in to change notification settings

rembertdesigns/f1-driver-performance-analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

46 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🏎️ F1 Driver Performance Analyzer

Launch Simulator

F1 Driver Performance Analyzer - Interactive dashboard for analyzing Formula 1 driver performance with AI-powered metrics, telemetry data, and head-to-head comparisons

An interactive, multi-view dashboard built with Python and Streamlit to analyze and compare Formula 1 driver performance from historical race data using FastF1 telemetry.

This application provides a comprehensive suite of tools for exploring lap times, comparing drivers head-to-head, analyzing teammate performance, breaking down stints, and even uses a machine learning model to generate performance scores for each driver.


✨ Key Features

Modern Tabbed Dashboard

A clean, intuitive user interface built with st.tabs that organizes different analyses into logical sections for easy navigation.

Interactive Data Visualization

All charts are created with Plotly for a rich, interactive experience, including tooltips, zoom, and pan capabilities.

Comprehensive Analysis Views

  • πŸ“Š Summary Insights: High-level race metrics including fastest average lap, most consistent stint, and biggest performance drop-off
  • ⚑ Fastest & Consistent: Identify the fastest single lap and most consistent driver performances
Screenshot 2025-08-12 at 11 00 22β€―AM
  • βš”οΈ Driver vs. Driver: Head-to-head lap time comparison between any two drivers in the race
Screenshot 2025-08-12 at 11 02 13β€―AM
  • πŸ‘₯ Teammate Comparison: The ultimate F1 benchmark - comparing drivers in identical machinery
Screenshot 2025-08-12 at 11 04 03β€―AM
  • πŸ§ͺ Stint Performance: Analyze pace degradation and performance across different tire stints
Screenshot 2025-08-12 at 11 08 32β€―AM
  • πŸ›ž Tyre Compounds: Performance analysis by tire compound (Soft, Medium, Hard)
Screenshot 2025-08-12 at 11 11 04β€―AM
  • 🧠 AI Driver Scoring: ML-powered performance scoring based on key race metrics
Screenshot 2025-08-12 at 11 15 49β€―AM

AI-Powered Performance Scoring

Integrates a pre-trained Scikit-learn model (driver_score_model.pkl) to generate comprehensive performance scores for each driver based on:

  • Pace relative to teammate
  • Lap time consistency (standard deviation)
  • Average stint length
  • Tire compound strategy

Robust Data Handling

  • Graceful handling of different CSV formats and missing data
  • Comprehensive error checking and user feedback
  • Dynamic filtering by year and race

πŸ› οΈ Technologies Used

  • Core: Python 3.10+
  • Data Analysis: FastF1, Pandas, NumPy
  • Visualization: Streamlit, Plotly Express
  • Machine Learning: Scikit-learn, Joblib
  • Model Explainability: SHAP (Shapley Additive Explanations)

🧱 Project Structure

f1-driver-performance-analyzer/
β”‚
β”œβ”€β”€ data/
β”‚   └── sessions/              # Race CSV files (auto-generated)
β”‚       └── YYYY_RaceName_RACE.csv
β”‚
β”œβ”€β”€ models/
β”‚   └── driver_score_model.pkl # Pre-trained ML model
β”‚
β”œβ”€β”€ streamlit_app/
β”‚   β”œβ”€β”€ app.py                 # Main Streamlit application
β”‚   └── inspect_model.py       # Model inspection utility
β”‚
β”œβ”€β”€ notebooks/
β”‚   └── EDA.ipynb             # Exploratory Data Analysis
β”‚
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ __init__.py
β”‚   └── data_loader.py        # FastF1 data collection script
β”‚
β”œβ”€β”€ train_model.py            # ML model training script
β”œβ”€β”€ requirements.txt          # Python dependencies
└── README.md

πŸš€ Quick Start

Prerequisites

  • Python 3.10 or newer
  • pip for package installation

Installation

  1. Clone the repository:
git clone https://github.com/rembertdesigns/f1-driver-performance-analyzer.git
cd f1-driver-performance-analyzer
  1. Create and activate a virtual environment (recommended):
python3 -m venv venv
source venv/bin/activate  # On macOS/Linux
# On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt

Data Collection

  1. Collect F1 race data using FastF1:
python src/data_loader.py

This will download race data from 2018-2024 and save CSV files to data/sessions/.

Model Training

  1. Train the AI scoring model:
python train_model.py

This creates driver_score_model.pkl in the models/ directory.

Running the Application

  1. Launch the Streamlit app:
streamlit run streamlit_app/app.py

Then open your browser to the URL shown (typically http://localhost:8501).


πŸ“Š How It Works

Data Pipeline

  1. FastF1 Integration: Automatically downloads telemetry data from Formula 1 races
  2. Feature Engineering: Calculates key performance metrics like pace vs. teammate and consistency
  3. ML Scoring: Uses linear regression to score driver performance holistically
  4. Interactive Visualization: Presents insights through dynamic Plotly charts

Key Metrics Explained

  • Pace vs. Teammate: How much faster/slower compared to team average
  • Consistency: Standard deviation of lap times (lower = more consistent)
  • Stint Analysis: Performance degradation over tire life
  • Compound Strategy: Performance differences across tire compounds

πŸ” Model Explainability

The project includes SHAP (SHapley Additive exPlanations) integration to understand:

  • Which features most influence driver scores
  • How individual predictions are made
  • Global feature importance across all drivers

See notebooks/EDA.ipynb for detailed model analysis and feature importance visualizations.


πŸ›£οΈ Future Enhancements

  • Real-time Data Integration: Live race analysis during GP weekends
  • Advanced Telemetry: Speed, throttle, and brake analysis using FastF1's full capabilities
  • Weather Impact Analysis: Correlation between weather conditions and performance
  • Qualifying Integration: Compare race pace to qualifying performance
  • Season-long Analytics: Championship standings and consistency over full seasons
  • Predictive Modeling: Predict race outcomes based on practice/qualifying data

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.


πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments

  • FastF1: For providing excellent F1 telemetry data access
  • Formula 1: For the amazing sport and data availability
  • Streamlit: For the fantastic web app framework
  • Plotly: For interactive visualization capabilities

⚠️ Important Notes

  • Race data is sourced from FastF1 and covers seasons from 2018-2024
  • Initial data download may take some time due to FastF1 caching
  • The ML model is trained on historical data and scores are relative to the dataset
  • Some races may have limited telemetry data depending on FastF1 availability

Releases

No releases published

Packages

No packages published