diff --git "a/notebooks/.ipynb_checkpoints/sector-3-time-prediction-checkpoint.ipynb" "b/notebooks/.ipynb_checkpoints/sector-3-time-prediction-checkpoint.ipynb" --- "a/notebooks/.ipynb_checkpoints/sector-3-time-prediction-checkpoint.ipynb" +++ "b/notebooks/.ipynb_checkpoints/sector-3-time-prediction-checkpoint.ipynb" @@ -44,7 +44,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -75,248 +75,48 @@ "source": [ "### Variables\n", "\n", - "- The main variables in the dataset:\n", - " - Speed (in km/h)\n", - " - Throttle Position (percentage)\n", - " - Gear (current gear)\n", - " - RPM (revolutions per minute)\n", - " - Lap Time (seconds)" + "The main variables in the dataset:\n", + "- _LapTime_: Recorded lap time.\n", + "- _Sector1Time_: Sector 1 recorded time\n", + "- _Sector2Time_: Sector 2 recorded time\n", + "- _Sector3Time_: Sector 3 recorded time\n", + "- _SpeedI1_: Speedtrap sector 1 [km/h]\n", + "- _SpeedI2_: Speedtrap sector 2 [km/h]\n", + "- _SpeedFL_: Speedtrap at finish line [km/h]\n", + "- _SpeedST_: Speedtrap on longest straight [km/h]\n", + "- _Compound_: Tyres event specific compound name: SOFT, MEDIUM, HARD, INTERMEDIATE, WET (the actual underlying compounds C1 to C5 are not differentiated).\n" ] }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ + "req WARNING \tDEFAULT CACHE ENABLED! (947.08 MB) /Users/diegomaradona/Library/Caches/fastf1\n", "core INFO \tLoading data for Emilia Romagna Grand Prix - Race [v3.3.6]\n", - "INFO:fastf1.fastf1.core:Loading data for Emilia Romagna Grand Prix - Race [v3.3.6]\n", "req INFO \tUsing cached data for session_info\n", - "INFO:fastf1.fastf1.req:Using cached data for session_info\n", "req INFO \tUsing cached data for driver_info\n", - "INFO:fastf1.fastf1.req:Using cached data for driver_info\n", "req INFO \tUsing cached data for session_status_data\n", - "INFO:fastf1.fastf1.req:Using cached data for session_status_data\n", "req INFO \tUsing cached data for lap_count\n", - "INFO:fastf1.fastf1.req:Using cached data for lap_count\n", "req INFO \tUsing cached data for track_status_data\n", - "INFO:fastf1.fastf1.req:Using cached data for track_status_data\n", "req INFO \tUsing cached data for _extended_timing_data\n", - "INFO:fastf1.fastf1.req:Using cached data for _extended_timing_data\n", "req INFO \tUsing cached data for timing_app_data\n", - "INFO:fastf1.fastf1.req:Using cached data for timing_app_data\n", "core INFO \tProcessing timing data...\n", - "INFO:fastf1.fastf1.core:Processing timing data...\n", "req INFO \tUsing cached data for car_data\n", - "INFO:fastf1.fastf1.req:Using cached data for car_data\n", "req INFO \tUsing cached data for position_data\n", - "INFO:fastf1.fastf1.req:Using cached data for position_data\n", - "core INFO \tFinished loading data for 20 drivers: ['1', '4', '16', '81', '55', '44', '63', '11', '18', '22', '27', '20', '3', '31', '24', '10', '2', '77', '14', '23']\n", - "INFO:fastf1.fastf1.core:Finished loading data for 20 drivers: ['1', '4', '16', '81', '55', '44', '63', '11', '18', '22', '27', '20', '3', '31', '24', '10', '2', '77', '14', '23']\n" + "core INFO \tFinished loading data for 20 drivers: ['1', '4', '16', '81', '55', '44', '63', '11', '18', '22', '27', '20', '3', '31', '24', '10', '2', '77', '14', '23']\n" ] - }, - { - "data": { - "text/html": [ - "
\n", - " | 315 | \n", - "
---|---|
Time | \n", - "0 days 00:57:04.002000 | \n", - "
Driver | \n", - "HAM | \n", - "
DriverNumber | \n", - "44 | \n", - "
LapTime | \n", - "0 days 00:01:27.111000 | \n", - "
LapNumber | \n", - "1.0 | \n", - "
Stint | \n", - "1.0 | \n", - "
PitOutTime | \n", - "NaT | \n", - "
PitInTime | \n", - "NaT | \n", - "
Sector1Time | \n", - "NaT | \n", - "
Sector2Time | \n", - "0 days 00:00:29.112000 | \n", - "
Sector3Time | \n", - "0 days 00:00:27.601000 | \n", - "
Sector1SessionTime | \n", - "NaT | \n", - "
Sector2SessionTime | \n", - "0 days 00:56:36.529000 | \n", - "
Sector3SessionTime | \n", - "0 days 00:57:04.177000 | \n", - "
SpeedI1 | \n", - "215.0 | \n", - "
SpeedI2 | \n", - "254.0 | \n", - "
SpeedFL | \n", - "278.0 | \n", - "
SpeedST | \n", - "279.0 | \n", - "
IsPersonalBest | \n", - "False | \n", - "
Compound | \n", - "MEDIUM | \n", - "
TyreLife | \n", - "1.0 | \n", - "
FreshTyre | \n", - "True | \n", - "
Team | \n", - "Mercedes | \n", - "
LapStartTime | \n", - "0 days 00:55:36.608000 | \n", - "
LapStartDate | \n", - "2024-05-19 13:03:16.594000 | \n", - "
TrackStatus | \n", - "1 | \n", - "
Position | \n", - "7.0 | \n", - "
Deleted | \n", - "None | \n", - "
DeletedReason | \n", - "\n", - " |
FastF1Generated | \n", - "False | \n", - "
IsAccurate | \n", - "False | \n", - "
Number of records: 45\n", + "Name : GRADIENT_BOOSTED_TREES
Task : REGRESSION
Label : Sector3Time
Features (7) : Stint Sector1Time Sector2Time SpeedI1 SpeedI2 Compound TyreLife
Weights : None
Trained with tuner : No
Model size : 41 kBNumber of records: 45\n", "Number of columns: 8\n", "\n", "Number of columns by type:\n", @@ -5470,16 +5376,16 @@ "Columns:\n", "\n", "NUMERICAL: 7 (87.5%)\n", - "\t0: "Sector3Time" NUMERICAL mean:27.2157 min:26.849 max:27.749 sd:0.23897\n", - "\t1: "Stint" NUMERICAL mean:1.66667 min:1 max:2 sd:0.471405\n", - "\t2: "Sector1Time" NUMERICAL mean:25.651 min:25.191 max:26.525 sd:0.201321\n", - "\t3: "Sector2Time" NUMERICAL mean:28.4221 min:27.961 max:29.206 sd:0.264305\n", - "\t4: "SpeedI1" NUMERICAL mean:213.956 min:206 max:220 sd:3.01076\n", - "\t5: "SpeedI2" NUMERICAL mean:254.978 min:247 max:260 sd:2.90967\n", - "\t7: "TyreLife" NUMERICAL mean:17.4889 min:2 max:36 sd:9.74479\n", + "\t0: "Sector3Time" NUMERICAL mean:27.2233 min:26.849 max:27.749 sd:0.245425\n", + "\t1: "Stint" NUMERICAL mean:1.62222 min:1 max:2 sd:0.484832\n", + "\t2: "Sector1Time" NUMERICAL mean:25.6412 min:25.191 max:25.983 sd:0.160483\n", + "\t3: "Sector2Time" NUMERICAL mean:28.4059 min:27.961 max:29.206 sd:0.256306\n", + "\t4: "SpeedI1" NUMERICAL mean:214.156 min:206 max:220 sd:2.98854\n", + "\t5: "SpeedI2" NUMERICAL mean:254.844 min:247 max:260 sd:2.95865\n", + "\t7: "TyreLife" NUMERICAL mean:17.2667 min:2 max:36 sd:9.71231\n", "\n", "CATEGORICAL: 1 (12.5%)\n", - "\t6: "Compound" CATEGORICAL has-dict vocab-size:3 zero-ood-items most-frequent:"HARD" 30 (66.6667%)\n", + "\t6: "Compound" CATEGORICAL has-dict vocab-size:3 zero-ood-items most-frequent:"HARD" 28 (62.2222%)\n", "\n", "Terminology:\n", "\tnas: Number of non-available (i.e. missing) values.\n", @@ -5488,20 +5394,20 @@ "\ttokenized: The attribute value is obtained through tokenization.\n", "\thas-dict: The attribute is attached to a string dictionary e.g. a categorical attribute stored as a string.\n", "\tvocab-size: Number of unique values.\n", - "The following evaluation is computed on the validation or out-of-bag dataset.
Number of predictions (with weights): 1\n", + "The following evaluation is computed on the validation or out-of-bag dataset.
Number of predictions (with weights): 1\n", "Task: REGRESSION\n", - "Loss (SQUARED_ERROR): 0.139805\n", + "Loss (SQUARED_ERROR): 0.0863763\n", "\n", - "RMSE: 0.373905\n", + "RMSE: 0.293898\n", "Default RMSE: : 0\n", "\n", - "\n", + "\n", "\n", "\n", - "\n", + "\n", "\n", - "Variable importances measure the importance of an input feature for a model.
1. "Sector2Time" 0.585075 ################\n", - " 2. "Sector1Time" 0.468401 ##########\n", - " 3. "TyreLife" 0.275431 \n", - " 4. "SpeedI1" 0.269395 \n", - " 5. "SpeedI2" 0.265563 \n", - " 6. "Compound" 0.257481 \n", - "1. "Sector2Time" 11.000000 ################\n", - " 2. "Sector1Time" 9.000000 ############\n", - " 3. "Compound" 1.000000 \n", - "1. "Sector1Time" 40.000000 ################\n", - " 2. "Sector2Time" 39.000000 ###############\n", - " 3. "TyreLife" 24.000000 #########\n", - " 4. "SpeedI1" 22.000000 ########\n", - " 5. "SpeedI2" 12.000000 ####\n", - " 6. "Compound" 1.000000 \n", - "1. "Sector1Time" 7.133759 ################\n", - " 2. "Sector2Time" 3.544437 #######\n", - " 3. "TyreLife" 0.822106 #\n", - " 4. "SpeedI1" 0.208323 \n", - " 5. "SpeedI2" 0.117112 \n", - " 6. "Compound" 0.037033 \n", - "Those variable importances are computed during training. More, and possibly more informative, variable importances are available when analyzing a model on a test dataset.
Num trees : 21Only printing the first tree.
Tree #0:\n", - " "Sector1Time">=25.7165 [s:0.0342993 n:43 np:16 miss:0] ; pred:1.77428e-08\n", - " ├─(pos)─ "Sector1Time">=25.8315 [s:0.0092188 n:16 np:5 miss:0] ; pred:0.0240583\n", - " | ├─(pos)─ pred:0.0382996\n", - " | └─(neg)─ "Sector1Time">=25.757 [s:0.00391536 n:11 np:6 miss:0] ; pred:0.017585\n", - " | ├─(pos)─ pred:0.0118729\n", - " | └─(neg)─ pred:0.0244395\n", - " └─(neg)─ "Sector2Time">=28.326 [s:0.0129139 n:27 np:11 miss:1] ; pred:-0.0142567\n", - " ├─(pos)─ "Sector2Time">=28.5395 [s:0.00226281 n:11 np:5 miss:0] ; pred:-0.000551345\n", - " | ├─(pos)─ pred:0.00465958\n", - " | └─(neg)─ pred:-0.00489378\n", - " └─(neg)─ "Sector1Time">=25.566 [s:0.00398122 n:16 np:5 miss:1] ; pred:-0.0236792\n", - " ├─(pos)─ pred:-0.0143204\n", - " └─(neg)─ "SpeedI1">=217.5 [s:0.00136502 n:11 np:5 miss:0] ; pred:-0.0279332\n", - " ├─(pos)─ pred:-0.0319804\n", - " └─(neg)─ pred:-0.0245605\n", + "Variable importances measure the importance of an input feature for a model.
1. "Sector2Time" 1.000000 ################\n", + " 2. "Sector1Time" 0.358417 #\n", + " 3. "TyreLife" 0.291115 \n", + " 4. "SpeedI2" 0.278986 \n", + " 5. "SpeedI1" 0.272727 \n", + "1. "Sector2Time" 11.000000 \n", + "1. "Sector1Time" 24.000000 ################\n", + " 2. "Sector2Time" 17.000000 ##########\n", + " 3. "TyreLife" 10.000000 #####\n", + " 4. "SpeedI1" 9.000000 ####\n", + " 5. "SpeedI2" 3.000000 \n", + "1. "Sector2Time" 8.021375 ################\n", + " 2. "Sector1Time" 1.475066 ##\n", + " 3. "TyreLife" 1.119095 #\n", + " 4. "SpeedI2" 0.310687 \n", + " 5. "SpeedI1" 0.151599 \n", + "Those variable importances are computed during training. More, and possibly more informative, variable importances are available when analyzing a model on a test dataset.
Num trees : 11Only printing the first tree.
Tree #0:\n", + " "Sector2Time">=28.321 [s:0.0385804 n:43 np:25 miss:1] ; pred:5.32283e-08\n", + " ├─(pos)─ "Sector1Time">=25.8315 [s:0.0108827 n:25 np:5 miss:0] ; pred:0.0166667\n", + " | ├─(pos)─ pred:0.0375307\n", + " | └─(neg)─ "Sector1Time">=25.6365 [s:0.00590318 n:20 np:12 miss:1] ; pred:0.0114507\n", + " | ├─(pos)─ "Sector1Time">=25.757 [s:0.00280898 n:12 np:6 miss:0] ; pred:0.0177241\n", + " | | ├─(pos)─ pred:0.0124241\n", + " | | └─(neg)─ pred:0.0230241\n", + " | └─(neg)─ pred:0.00204077\n", + " └─(neg)─ "SpeedI1">=216.5 [s:0.00187296 n:18 np:9 miss:0] ; pred:-0.0231481\n", + " ├─(pos)─ pred:-0.0274759\n", + " └─(neg)─ pred:-0.0188204\n", "
Variable importances measure the importance of an input feature for a model.
1. "Sector2Time" 0.003584 ################\n", - " 2. "SpeedI2" 0.000145 ##########\n", - " 3. "Stint" -0.000000 #########\n", - " 4. "Sector1Time" -0.000000 #########\n", - " 5. "TyreLife" -0.003074 ####\n", - " 6. "Compound" -0.005478 \n", - " 7. "SpeedI1" -0.005612 \n", - "
1. "Sector2Time" 0.585075 ################\n", - " 2. "Sector1Time" 0.468401 ##########\n", - " 3. "TyreLife" 0.275431 \n", - " 4. "SpeedI1" 0.269395 \n", - " 5. "SpeedI2" 0.265563 \n", - " 6. "Compound" 0.257481 \n", - "
1. "Sector2Time" 11.000000 ################\n", - " 2. "Sector1Time" 9.000000 ############\n", - " 3. "Compound" 1.000000 \n", - "
1. "Sector1Time" 40.000000 ################\n", - " 2. "Sector2Time" 39.000000 ###############\n", - " 3. "TyreLife" 24.000000 #########\n", - " 4. "SpeedI1" 22.000000 ########\n", - " 5. "SpeedI2" 12.000000 ####\n", - " 6. "Compound" 1.000000 \n", - "
1. "Sector1Time" 7.133759 ################\n", - " 2. "Sector2Time" 3.544437 #######\n", - " 3. "TyreLife" 0.822106 #\n", - " 4. "SpeedI1" 0.208323 \n", - " 5. "SpeedI2" 0.117112 \n", - " 6. "Compound" 0.037033 \n", + "
Variable importances measure the importance of an input feature for a model.
1. "Sector1Time" 0.063597 ################\n", + " 2. "SpeedI1" 0.001515 ###\n", + " 3. "SpeedI2" 0.000022 ###\n", + " 4. "Stint" -0.000000 ###\n", + " 5. "Compound" -0.000000 ###\n", + " 6. "Sector2Time" -0.009947 #\n", + " 7. "TyreLife" -0.017248 \n", + "
1. "Sector2Time" 1.000000 ################\n", + " 2. "Sector1Time" 0.358417 #\n", + " 3. "TyreLife" 0.291115 \n", + " 4. "SpeedI2" 0.278986 \n", + " 5. "SpeedI1" 0.272727 \n", + "
1. "Sector2Time" 11.000000 \n", + "
1. "Sector1Time" 24.000000 ################\n", + " 2. "Sector2Time" 17.000000 ##########\n", + " 3. "TyreLife" 10.000000 #####\n", + " 4. "SpeedI1" 9.000000 ####\n", + " 5. "SpeedI2" 3.000000 \n", + "
1. "Sector2Time" 8.021375 ################\n", + " 2. "Sector1Time" 1.475066 ##\n", + " 3. "TyreLife" 1.119095 #\n", + " 4. "SpeedI2" 0.310687 \n", + " 5. "SpeedI1" 0.151599 \n", "