Formula 1 Lap Time Prediction and Evaluation

Andre Contreras


This project I did focuses on trying to predict a driver’s laptime on __ lap in the _____ Grand Prix using a linear regression model I created for that race. The first section is the pre-race predictions, which contains the prediction of the lap 30 time of Sergio Perez in every race of the 2024 F1 season, along with the Root Mean Squared Error of the model’s testing predictions. The second section is the post-race analysis, which evaluates the predicted laptime of that race’s lap and outputs the difference. It also displays informative plots summarizing the race.

(The default driver is Sergio Perez, default lap is 30. I still need to implement user interface in this page so that it takes the driver, lap, circuit you want to test and output the predicted lap time)

The code I used for this project can be found in my GitHub Repository: https://github.com/andrejcc04/Portfolio/blob/main/FormulaOne.Rmd

_______________________________________________________________________________

Pre-Race Lap Time Predictions

Note: 1 second = 1000 milliseconds

2024 Bahrain Grand Prix (Bahrain)

## Predicted lap time of Sergio Pérez on lap 30 in the 2024 Bahrain Grand Prix: 1:38:73
## Root Mean Squared Error: 1513 milliseconds

2024 Saudi Arabian Grand Prix (Jeddah)

## Predicted lap time of Sergio Pérez on lap 30 in the 2024 Saudi Arabian Grand Prix: 1:35:151
## Root Mean Squared Error: 1269 milliseconds

2024 Autralian Grand Prix (Melbourne)

## Predicted lap time of Sergio Pérez on lap 30 in the 2024 Australian Grand Prix: 1:21:268
## Root Mean Squared Error: 2551 milliseconds

2024 Japanese Grand Prix (Suzuka)

## Predicted lap time of Sergio Pérez on lap 30 in the 2024 Japanese Grand Prix: 1:37:471
## Root Mean Squared Error: 1740 milliseconds

2024 Chinese Grand Prix (Shanghai)

## Predicted lap time of Sergio Pérez on lap 30 in the 2024 Chinese Grand Prix: 1:41:449
## Root Mean Squared Error: 1187 milliseconds

2024 Miami Grand Prix (Miami)

## Predicted lap time of Sergio Pérez on lap 30 in the 2024 Miami Grand Prix: 1:31:51
## Root Mean Squared Error: 2652 milliseconds

2024 Emilia-Romagna Grand Prix (Imola)

## Predicted lap time of Sergio Pérez on lap 30 in the 2024 Imola Grand Prix: 1:22:301
## Root Mean Squared Error: 1069 milliseconds

2024 Monaco Grand Prix (Monte Carlo)

## Predicted lap time of Sergio Pérez on lap 30 in the 2024 Monaco Grand Prix: 1:17:860
## Root Mean Squared Error: 1472 milliseconds

2024 Canadian Grand Prix (Montreal)

## Predicted lap time of Sergio Pérez on lap 30 in the 2024 Canadian Grand Prix: 1:17:701
## Root Mean Squared Error: 862 milliseconds

2024 Spanish Grand Prix (Catalunya)

## Predicted lap time of Sergio Pérez on lap 30 in the 2024 Canadian Grand Prix: 1:20:572
## Root Mean Squared Error: 3317 milliseconds

2024 Austrian Grand Prix (Spielberg)

## Predicted lap time of Sergio Pérez on lap 30 in the 2024 Austrian Grand Prix: 1:11:125
## Root Mean Squared Error: 843 milliseconds

2024 British Grand Prix (Silverstone)

## Predicted lap time of Sergio Pérez on lap 30 in the 2024 British Grand Prix: 1:32:890
## Root Mean Squared Error: 869 milliseconds

2024 Hungarian Grand Prix (Budapest)

## Predicted lap time of Sergio Pérez on lap 30 in the 2024 Hungarian Grand Prix: 1:25:388
## Root Mean Squared Error: 894 milliseconds

2024 Belgian Grand Prix (Spa)

## Predicted lap time of Sergio Pérez on lap 30 in the 2024 Belgian Grand Prix: 1:51:495
## Root Mean Squared Error: 1189 milliseconds

2024 Dutch Grand Prix (Zandvoort)

## Predicted lap time of Sergio Pérez on lap 30 in the 2024 Dutch Grand Prix: 1:14:588
## Root Mean Squared Error: 1411 milliseconds

2024 Italian Grand Prix (Monza)

## Predicted lap time of Sergio Pérez on lap 30 in the 2024 Italian Grand Prix: 1:26:820
## Root Mean Squared Error: 752 milliseconds

2024 Azerbaijan Grand Prix (Baku)

## Predicted lap time of Sergio Pérez on lap 30 in the 2024 Azerbaijan Grand Prix: 1:47:263
## Root Mean Squared Error: 1152 milliseconds

2024 Singapore Grand Prix (Marina Bay)

## Predicted lap time of Sergio Pérez on lap 30 in the 2024 Singapore Grand Prix: 1:40:160
## Root Mean Squared Error: 927 milliseconds

2024 United States Grand Prix (Austin)

## Predicted lap time of Sergio Pérez on lap 30 in the 2024 United States Grand Prix: 1:41:427
## Root Mean Squared Error: 1033 milliseconds

2024 Mexican Grand Prix (Mexico City)

## Predicted lap time of Sergio Pérez on lap 30 in the 2024 Mexican Grand Prix: 1:23:885
## Root Mean Squared Error: 774 milliseconds

2024 Brazilian Grand Prix (Sao Paulo)

## Predicted lap time of Sergio Pérez on lap 30 in the 2024 Brazilian Grand Prix: 1:15:887
## Root Mean Squared Error: 818 milliseconds

2024 Las Vegas Grand Prix (Las Vegas)

## Predicted lap time of Sergio Pérez on lap 30 in the 2024 Las Vegas Grand Prix: 1:38:655
## Root Mean Squared Error: 1131 milliseconds

2024 Qatar Grand Prix (Losail)

## Predicted lap time of Sergio Pérez on lap 30 in the 2024 Qatar Grand Prix: 1:28:359
## Root Mean Squared Error: 883 milliseconds

2024 Abu Dhabi Grand Prix (Abi Dhabi)

## Predicted lap time of Sergio Pérez on lap 30 in the 2024 Abu Dhabi Grand Prix: 1:26:812
## Root Mean Squared Error: 680 milliseconds

____________________________________________________________________________

Post-Race Data Analysis

2024 Bahrain Grand Prix Post-Race Analysis and Evaluation

##   forename surname year               name lap Predicted Laptime Actual Laptime
## 1   Sergio   Pérez 2024 Bahrain Grand Prix  30             98073          96313
## Off by 1760 milliseconds
## [[1]]

## 
## [[2]]

## 
## [[3]]

2024 Saudi Arabian Grand Prix Post-Race Analysis and Evaluation

##   forename surname year                     name lap Predicted Laptime
## 1   Sergio   Pérez 2024 Saudi Arabian Grand Prix  30             95151
##   Actual Laptime
## 1          92782
## Off by 2369 milliseconds
## [[1]]

## 
## [[2]]

## 
## [[3]]

2024 Australian Grand Prix Post-Race Analysis and Evaluation

##   forename surname year                  name lap Predicted Laptime
## 1   Sergio   Pérez 2024 Australian Grand Prix  30             81268
##   Actual Laptime
## 1          82180
## Off by 912 milliseconds
## [[1]]

## 
## [[2]]

## 
## [[3]]

2024 Japanese Grand Prix Post-Race Analysis and Evaluation

##   forename surname year                name lap Predicted Laptime
## 1   Sergio   Pérez 2024 Japanese Grand Prix  30             97471
##   Actual Laptime
## 1          97097
## Off by 374 milliseconds
## [[1]]

## 
## [[2]]

## 
## [[3]]

2024 Chinese Grand Prix Post-Race Analysis and Evaluation

##   forename surname year               name lap Predicted Laptime Actual Laptime
## 1   Sergio   Pérez 2024 Chinese Grand Prix  30            101449         141644
## Off by 40195 milliseconds (Safety Car lap 21-31)
## [[1]]

## 
## [[2]]

## 
## [[3]]

2024 Miami Grand Prix Post-Race Analysis and Evaluation

##   forename surname year             name lap Predicted Laptime Actual Laptime
## 1   Sergio   Pérez 2024 Miami Grand Prix  30             91051         120593
## Off by 29542 milliseconds (Safety Car lap 28-32)
## [[1]]

## 
## [[2]]

## 
## [[3]]

2024 Emilia-Romagna Grand Prix Post-Race Analysis and Evaluation

##   forename surname year                      name lap Predicted Laptime
## 1   Sergio   Pérez 2024 Emilia Romagna Grand Prix  30             82301
##   Actual Laptime
## 1          83263
## Off by 962 milliseconds
## [[1]]

## 
## [[2]]

## 
## [[3]]

2024 Monaco Grand Prix Post-Race Analysis and Evaluation

##   forename surname year              name lap Predicted Laptime Actual Laptime
## 1   Sergio   Pérez 2024 Monaco Grand Prix  30             77860             NA
## Off by NA milliseconds (Crashed out lap 1)
## [[1]]

## 
## [[2]]

## 
## [[3]]

2024 Canadian Grand Prix Post-Race Analysis and Evaluation

##   forename surname year                name lap Predicted Laptime
## 1   Sergio   Pérez 2024 Canadian Grand Prix  30          77701.42
##   Actual Laptime
## 1          89333
## Off by 11631.58 milliseconds (Rain)
## [[1]]

## 
## [[2]]

## 
## [[3]]