Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

F1 Predictive Analysis System

Objective

This project analyzes Formula 1 race data for two selected drivers using the FastF1 API. It compares lap times, builds polynomial regression models, predicts future lap times, estimates tire degradation, and generates a visual comparison chart.

Installation

1. Open PowerShell in the project directory

cd path\to\f1-predictive-analysis

2. Create a virtual environment

python -m venv .venv

3. Activate the virtual environment

.\.venv\Scripts\Activate.ps1

If PowerShell prevents activation because of its execution policy, the project can still be installed and run by calling the virtual environment's Python executable directly.

4. Install the required libraries

.\.venv\Scripts\python.exe -m pip install -r requirements.txt

An internet connection is required during installation and when downloading race data for the first time. Downloaded FastF1 data is stored in the f1_cache directory, making later runs faster.

Required Libraries

  • fastf1 — downloads and processes Formula 1 race data
  • pandas — manages lap and session data
  • numpy — performs numerical calculations
  • matplotlib — creates the analysis graph
  • scikit-learn — provides regression models and the R² score

The tested, pinned versions are listed in requirements.txt.

Running the Project

The easiest way to start the program is:

.\run_f1_analysis.ps1

Alternatively, run the Python file directly:

.\.venv\Scripts\python.exe .\F1Predictive_analysis.py

When prompted:

  1. Enter a season year, such as 2023.
  2. Enter a Grand Prix name, such as Monaco.
  3. Select two driver codes from the displayed list, such as VER and ALO.
  4. View the generated graph.
  5. Enter lap numbers to receive predictions, or enter 0 to exit.

Expected Output

The terminal displays:

  • Available drivers for the selected race
  • Each driver's fastest and average lap time
  • The time difference between the drivers
  • Polynomial regression R² scores
  • Estimated tire-degradation rates
  • Predicted lap times for requested lap numbers

The project also displays and saves a graph containing:

  • Driver lap times and polynomial regression curves
  • Model residuals
  • Lap-time distributions
  • Tire-degradation values

The graph is saved as:

f1_predictive_analysis.png

It is always written to the same directory as F1Predictive_analysis.py.

About

Formula 1 lap-time comparison and predictive analysis using FastF1 and polynomial regression

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages