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.
A clean, intuitive user interface built with st.tabs that organizes different analyses into logical sections for easy navigation.
All charts are created with Plotly for a rich, interactive experience, including tooltips, zoom, and pan capabilities.
- π 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
- βοΈ Driver vs. Driver: Head-to-head lap time comparison between any two drivers in the race
- π₯ Teammate Comparison: The ultimate F1 benchmark - comparing drivers in identical machinery
- π§ͺ Stint Performance: Analyze pace degradation and performance across different tire stints
- π Tyre Compounds: Performance analysis by tire compound (Soft, Medium, Hard)
- π§ AI Driver Scoring: ML-powered performance scoring based on key race metrics
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
- Graceful handling of different CSV formats and missing data
- Comprehensive error checking and user feedback
- Dynamic filtering by year and race
- Core: Python 3.10+
- Data Analysis: FastF1, Pandas, NumPy
- Visualization: Streamlit, Plotly Express
- Machine Learning: Scikit-learn, Joblib
- Model Explainability: SHAP (Shapley Additive Explanations)
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- Python 3.10 or newer
pipfor package installation
- Clone the repository:
git clone https://github.com/rembertdesigns/f1-driver-performance-analyzer.git
cd f1-driver-performance-analyzer- Create and activate a virtual environment (recommended):
python3 -m venv venv
source venv/bin/activate # On macOS/Linux
# On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Collect F1 race data using FastF1:
python src/data_loader.pyThis will download race data from 2018-2024 and save CSV files to data/sessions/.
- Train the AI scoring model:
python train_model.pyThis creates driver_score_model.pkl in the models/ directory.
- Launch the Streamlit app:
streamlit run streamlit_app/app.pyThen open your browser to the URL shown (typically http://localhost:8501).
- FastF1 Integration: Automatically downloads telemetry data from Formula 1 races
- Feature Engineering: Calculates key performance metrics like pace vs. teammate and consistency
- ML Scoring: Uses linear regression to score driver performance holistically
- Interactive Visualization: Presents insights through dynamic Plotly charts
- 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
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.
- 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
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.
This project is licensed under the MIT License - see the LICENSE file for details.
- 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
- 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
