openf1-ml-dataset / README.md
HiddenTerps's picture
OpenF1 ML dataset
fb678a1
|
Raw History Blame Contribute Delete
32.5 kB
---
pretty_name: OpenF1 ML Dataset
license: other
license_name: mixed-openf1-community
license_link: LICENSE
tags:
- formula1
- f1
- motorsport
- tabular
- time-series
task_categories:
- tabular-regression
- tabular-classification
size_categories:
- 100K<n<1M
configs:
- config_name: laps_ml
default: true
data_files:
- split: train
path: data/laps_ml/train.parquet
- config_name: laps
data_files:
- split: train
path: data/laps/train.parquet
- config_name: pit
data_files:
- split: train
path: data/pit/train.parquet
- config_name: stints
data_files:
- split: train
path: data/stints/train.parquet
- config_name: position
data_files:
- split: train
path: data/position/train.parquet
- config_name: weather
data_files:
- split: train
path: data/weather/train.parquet
- config_name: race_control
data_files:
- split: train
path: data/race_control/train.parquet
- config_name: drivers
data_files:
- split: train
path: data/drivers/train.parquet
- config_name: sessions
data_files:
- split: train
path: data/sessions/train.parquet
- config_name: meetings
data_files:
- split: train
path: data/meetings/train.parquet
- config_name: sessions_all
data_files:
- split: train
path: data/sessions_all/train.parquet
- config_name: car_data_sample
data_files:
- split: train
path: data/car_data_sample/train.parquet
- config_name: location_sample
data_files:
- split: train
path: data/location_sample/train.parquet
---
# OpenF1 ML Dataset
Lap-level Formula 1 timing for machine learning, covering completed **Race** and **Qualifying** sessions from 2023 through the 2026 Las Vegas Grand Prix. The default table is `laps_ml`: one row per lap, already joined to tyre stints, weather, position, and pit visits.
This is a derived compilation from the public [OpenF1 API](https://api.openf1.org/v1), with documented holes filled from [Jolpica](https://github.com/jolpica/jolpica-f1) and [TracingInsights](https://github.com/TracingInsights). It is **not official F1 timing** and is not affiliated with Formula 1, the FIA, or Formula One Management.
The dataset is public. OpenF1 describes its historical data as intended for educational use, personal learning, research, and non-commercial fan engagement — see [License](#license).
## Coverage
Pulled from OpenF1 on **24 Nov 2026, 23:23 America/Sao_Paulo** (25 Nov 2026, 02:23 UTC). No API key was used.
| Year | Qualifying | Race | Notes |
| ---: | ---: | ---: | --- |
| 2023 | 22 | 22 | Emilia-Romagna / Imola cancelled |
| 2024 | 24 | 24 | Complete |
| 2025 | 24 | 24 | Baku Qualifying laps come from TracingInsights |
| 2026 | 21 | 21 | Bahrain and Saudi Arabia cancelled; Qatar and Abu Dhabi were still in the future at fetch time |
Session window: **4 Mar 2023, 12:00 America/Sao_Paulo** (`2023-03-04T15:00:00Z`, Bahrain Qualifying) through **22 Nov 2026, 03:00 America/Sao_Paulo** (`2026-11-22T06:00:00Z`, Las Vegas Race).
`laps_ml` has **132,024** rows across **182** sessions (102,442 Race, 29,582 Qualifying): 2023 31,909; 2024 34,227; 2025 34,176; 2026 31,712. Practice, Sprint, and Sprint Qualifying are listed only in `sessions_all`.
## Tables
Parquet only, one file per table: `data/<table>/train.parquet`.
| Config | Rows | What it is |
| --- | ---: | --- |
| `laps_ml` (default) | 132,024 | Modelling table, same grain as `laps` |
| `laps` | 132,024 | Raw lap times, sectors, speed traps, `source` |
| `pit` | 12,625 | Pit visits with `pit_duration`, `lane_duration`, `source` |
| `stints` | 13,940 | Tyre compound and stint window |
| `position` | 165,611 | Position snapshots during the session |
| `weather` | 22,371 | Track/air temp, rain, wind, pressure, humidity |
| `race_control` | 15,511 | Flags, safety car, investigations, messages |
| `drivers` | 3,720 | Driver/team entry per session |
| `sessions` | 182 | Race + Qualifying sessions in the modelling tables |
| `meetings` | 101 | All meetings 2023–2026, including cancelled and future weekends |
| `sessions_all` | 495 | Every session OpenF1 returned for those years |
| `car_data_sample` | 33,653 | ~3.7 Hz car telemetry, one race / one driver only |
| `location_sample` | 34,452 | XYZ location, same sample |
Timestamps are UTC (`datetime64[ns, UTC]`). Integer columns that can be missing use pandas `Int64`. Rows are sorted and de-duplicated (see packing notes below).
### `laps_ml` schema
One row per `(session_key, driver_number, lap_number)`.
| Column | Source | Notes |
| --- | --- | --- |
| `year`, `meeting_key`, `meeting_name`, `meeting_official_name` | meetings | |
| `session_key`, `session_name`, `session_type`, `session_date_start`, `date_end`, `gmt_offset` | sessions | `session_name` is `Race` or `Qualifying` |
| `circuit_short_name`, `country_name`, `location` | sessions | |
| `driver_number`, `full_name`, `name_acronym`, `team_name`, `broadcast_name`, `country_code`, `country_code_source` | drivers | `country_code_source` is `openf1`, `openf1_other_session`, or `jolpica` |
| `lap_number`, `date_start`, `date_start_source`, `lap_duration`, `lap_duration_source`, `lap_time_missing_reason` | laps | Duration in seconds. `lap_time_missing_reason` is `timed`, or one of `structural_pit_out_untimed`, `structural_pit_in_untimed`, `structural_untimed_or_aborted`, `structural_dns_or_failed_start`. `*_source` may also be `derived_sector_sum` or `derived_session_lap1_start` |
| `duration_sector_1/2/3` and their `*_source` columns | laps | A missing sector can be `derived_sector_identity` = `lap_duration −` the other two when both are known, the result is &gt; 0 and it is at most 1.5× the session median of official values for that sector (33 laps, mostly race lap 1). Pit-out sector 1 and pit-in sector 3 stay null: they are not timed and would only contain pit-lane / garage time |
| `i1_speed`, `i2_speed`, `st_speed` and their `*_source` columns | laps | Speeds in km/h. Remaining nulls are untimed laps or feed gaps (see Null values) |
| `is_pit_out_lap`, `is_pit_in_lap`, `is_deleted`, `has_deletion_status` | laps / TracingInsights / pit table | `is_pit_in_lap` comes from TracingInsights `pin`, or is derived from the pit table when there is no TI row (173 laps, all False). `is_deleted` comes from TI `del`; the same 173 laps stay null — use `has_deletion_status` |
| `segments_sector_1/2/3`, `has_mini_sectors` | laps | Official OpenF1 mini-sector arrays. Residual holes (including all 335 Baku 2025 Qualifying laps) have no free source; TI’s compact digit strings were **not** copied in (full-array agreement with OpenF1 is only 34.7%). Filter on `has_mini_sectors` |
| `stint_number`, `compound`, `tyre_age_at_start`, `tyre_age`, `lap_start`, `lap_end`, plus `stint_number_source`, `compound_source`, `tyre_age_source` | stints / TracingInsights / derived | Prefer `tyre_age = tyre_age_at_start + (lap_number - lap_start)`. A retirement lap that sits exactly one lap after the driver’s last official stint inherits that stint (`derived_stint_extension`). TI `life` is stored as `tyre_age = life - 1` |
| `air_temperature`, `track_temperature`, `humidity`, `rainfall`, `pressure`, `wind_speed`, `wind_direction`, `weather_date`, `weather_source` | weather | Nearest weather row in the same session to `date_start`. After a `date_start` fill, weather is re-joined (`openf1_asof_after_date_fill`) |
| `position_at_lap`, `position_date`, `position_at_lap_source` | position | Prefer last snapshot at or before `date_start` (`openf1_asof_after_date_fill`). If none exists, the first later snapshot is used and tagged `openf1_asof_forward` |
| `final_position`, `final_position_source`, `final_position_openf1_snapshot` | Jolpica / position | Official classification: Race finishing order (Jolpica `position`, retirements included in classified order) or Qualifying position. `final_position_source` is `jolpica_official_classification`, `jolpica_qualifying_times_reranked` (5 Qualifying sessions where Jolpica positions were duplicated; re-ranked from Jolpica’s own Q1/Q2/Q3 times) or `openf1_last_position_snapshot` (2 drivers absent from Jolpica). `final_position_openf1_snapshot` keeps the last OpenF1 position snapshot, which misses post-session penalties and is often stale in Qualifying. **Target leak** for any lap-level model — see ML pitfalls |
| `pit_this_lap`, `pit_duration`, `stop_duration`, `lane_duration`, `pit_source`, `has_stop_duration` | pit | `pit_this_lap` is 1 if a pit visit is recorded on that lap. `stop_duration` is not invented; filter on `has_stop_duration` |
| `lap_source` | laps | `openf1` or `tracinginsights` (789 laps: 335 Baku 2025 Qualifying, 447 Miami 2025 Race laps 1–25, 7 Monza 2023 Race lap 51) |
Compounds observed: HARD, MEDIUM, SOFT, INTERMEDIATE, WET, plus a handful of `UNKNOWN` / null.
The telemetry sample (`car_data_sample`, `location_sample`) is Max Verstappen (`driver_number=1`) at the 2025 Abu Dhabi Grand Prix Race (`session_key=9839`) only. In 2026 the #1 car is Lando Norris; this sample is from 2025.
## Provenance
Provenance is in `source` (on `laps` and `pit`), `lap_source`, `pit_source`, and the `*_source` columns on filled fields. A non-null OpenF1 value is never overwritten.
| Tag | What it is |
| --- | --- |
| `openf1` | Public OpenF1 API (`https://api.openf1.org/v1`) |
| `openf1_other_session` | Copied from another session of the same driver (for `country_code` and `headshot_url`) |
| `openf1_asof_after_date_fill` | Weather or position re-joined from the existing OpenF1 tables after a missing `date_start` was filled (backward / nearest) |
| `openf1_asof_forward` | Position taken from the first OpenF1 snapshot *after* `date_start`, only when no snapshot exists at or before that instant |
| `jolpica` | Jolpica / Ergast-compatible API: 2023 Race pit stops, and driver nationality → `country_code` when OpenF1 had no code |
| `tracinginsights` | Public TracingInsights `session_laptimes.json` (2023–2024 MIT; 2025–2026 Apache-2.0) |
| `derived_sector_identity` | Missing sector = `lap_duration −` the other two known sectors (only if the result is &gt; 0 and ≤ 1.5× the session median for that sector) |
| `openf1_nearest_valid_track_temp` | `weather_source` on 53 laps whose nearest weather row had the OpenF1 `track_temperature = 0.0` sentinel; track temperature taken from the nearest valid reading of the same session (other weather fields unchanged) |
| `jolpica_official_classification` / `jolpica_qualifying_times_reranked` / `openf1_last_position_snapshot` | `final_position_source` values (see schema) |
| `derived_sector_sum` | Missing `lap_duration` = sum of all three sectors |
| `derived_session_lap1_start` | Race lap-1 `date_start` taken from the other drivers’ identical lap-1 start in the same session |
| `derived_stint_extension` | Compound / stint / tyre age / `lap_end` copied from the driver’s last official stint onto the next contiguous lap |
| `derived_session_only_compound` | Compound filled because every known stint in that session used the same compound |
| `derived_stint_formula` | `tyre_age = tyre_age_at_start + (lap_number − lap_start)` after a window was assigned |
| `derived_from_pit_table` | `is_pit_in_lap` derived from whether a pit row exists on the lap |
Full fill notes are in `gapfill_report.json`, `nullfill_report.json`, `residue_fill_report.json` and `qa_fix_report.json`.
## Null values
Many columns that look “full of nulls” are structural: the field does not apply on that row. Others were gaps in the OpenF1 feed and have been filled from TracingInsights, Jolpica, or a documented derivation. Remaining nulls were not invented. Boolean flags (`has_stop_duration`, `has_mini_sectors`, `has_headshot`, `has_deletion_status`) make the genuinely unavailable fields explicit.
### `laps_ml` key columns (original OpenF1-only → after all fills)
| Column | Original / prior | Now | What happened |
| --- | ---: | ---: | --- |
| `country_code` | 49.74% (65,441) | **0%** | Filled from the same driver in another session, or from Jolpica nationality (IOC-style codes, e.g. Brazilian → `BRA`, Danish → `DEN` to match OpenF1). |
| `duration_sector_1` | 6.07% → 5.91% (7,773) | **5.87%** (7,749) | **Mostly structural.** 7,231 are pit-out laps: OpenF1 never publishes an out-lap sector 1 of 100 s or more (max 99.8 s), because on a garage/pit exit the sector contains pit-lane or garage time. An earlier version filled 5,483 of these with `lap_duration − s2 − s3` (median 319 s — garage dwell, not a sector time); the QA pass reverted them. 33 identity fills remain (≤ 1.5× session median, mostly race lap 1). The identity itself holds on **99.980%** of 122,366 complete laps (24 official inconsistencies, mostly a ~0.51 s offset on 2024 Las Vegas Race). Also: 402 pit-in, 2,160 with no lap time. 82 timed non-pit laps have no sector 1 (red-flag / suspended laps where the stoppage cannot be attributed to a sector, e.g. 2026 Monza Race, plus one driver at 2025 Sakhir Race laps 38–57) — **unavailable**, not invented. |
| `duration_sector_2` | 0.58% → 0.57% (747) | **0.57%** (754) | 1 identity fill kept (2 reverted as implausible). Residual: 463 pit-in, 630 with no lap time. 36 timed non-pit laps have no sector 2 (20 at 2025 Sakhir Race, 7 at 2023 Monza Race lap 51 from TracingInsights). |
| `duration_sector_3` | 1.87% (2,458) | **1.87%** (2,466) | **Mostly structural.** 2,076 are pit-in laps (sector 3 ends in the pit lane; OpenF1 never publishes an in-lap sector 3 ≥ 100 s). The 752 earlier identity fills (all ≥ 100 s, garage / red-flag time) were reverted. 1,574 also have no lap time. 43 timed non-pit laps have no sector 3 (20 at 2025 Sakhir Race, 15 at 2026 Kuala Lumpur Race red flag, 7 at 2023 Monza lap 51). |
| `lap_duration` | 2.52% → 2.49% (3,271) | **2.48%** (3,269) | 3 filled as the sum of all three sectors (`derived_sector_sum`). Every remaining null is untimed: 1,807 pit-out, 1,151 pit-in, 307 aborted/incomplete laps with no official time in OpenF1, TracingInsights or the other two sectors (incl. #7 Doohan, 2025 Miami lap 1), and 4 DNS / failed starts. See `lap_time_missing_reason`. None of the 3,269 leftover rows is a timed flying lap. |
| `date_start` | 0.21% (273) → 4 | **0%** | 269 from TracingInsights `lSD`. The last 4 (2026 Melbourne Race #27 Hülkenberg and #81 Piastri; 2026 Shanghai Race #5 Bortoleto and #81 Piastri, all lap 1, no further laps) use the other drivers’ race-start timestamp, which is identical across the grid to the millisecond (`derived_session_lap1_start`, peer spread 0.0 s). |
| `air_temperature` (and the other weather fields) | 0.21% → 4 | **0%** | Re-joined from the OpenF1 weather table after the 4 `date_start` values were filled. |
| `position_at_lap` | 0.28% → 0.07% (98) | **0%** | 4 re-joined backward after the race-start fill. The other 94 (early 2026 Qualifying out-laps at Melbourne, Miami and Montreal, plus those two races’ DNS laps before the restore) had no snapshot at or before `date_start`; the first later OpenF1 snapshot was used (`openf1_asof_forward`). Median lag 91.5 s, max 209 s. This is the next official position, not a position invented at lap start. |
| `compound` | 0.21% → 0.12% (162) | **0.0008%** (1) | Official stints re-joined, 8 Spielberg 2025 Qualifying stints filled `SOFT` because every known compound in that session is SOFT (`derived_session_only_compound`), and 248 contiguous retirement laps inherited the driver’s last stint (`derived_stint_extension`). The one leftover is Piastri, 2026 Melbourne Race lap 1: DNS, no stint row in any source. |
| `tyre_age` | 0.19% → 0.11% (140) | **0.0008%** (1) | Same DNS row. Prefer the stint formula when `tyre_age_at_start` is present. |
| `stint_number` | 0.19% → 0.10% (138) | **0.0008%** (1) | Same DNS row. |
| `tyre_age_at_start`, `lap_start`, `lap_end` | 0.19% (253) | **0.0038%** (5) | The DNS row, plus 4 untimed laps that already have a TI compound/stint but sit 3–44 laps after the official window (not contiguous, so the window was not extended): 2025 Melbourne Race BOR 46 and LAW 47, 2025 Miami Race BOR 31, 2026 Kuala Lumpur Race BOT 8. |
| `i1_speed` | 12.02% → 0.34% (443) | **0.34%** (451) | 401 also have no lap time (structural untimed). 8 timed non-pit laps have no i1 in either source — unavailable. |
| `st_speed` | 7.84% → 0.71% (939) | **0.72%** (947) | 804 also have no lap time. 22 timed non-pit laps have no speed-trap reading (scattered Singapore / Hungaroring / Zandvoort / Interlagos races) — unavailable. |
| `i2_speed` | 1.28% → 1.22% (1,603) | **1.22%** (1,611) | 634 also have no lap time. **840 timed laps of the 2025 Las Vegas Race** (plus 7 at 2023 Monza lap 51) have no i2 in OpenF1 or TracingInsights (100% of that race’s i2 is missing — a feed gap). Not invented. |
| `pit_duration` / `lane_duration` | 92.40% | 92.42% (122,014) | **Structural.** Null on the 119,422 laps that are not a pit visit (`pit_this_lap = 0`). Among pit visits, 20.6% still have no duration: first outing from the garage or a final in-lap with no matching out-lap. That is not a completed pit-lane interval. |
| `stop_duration` | 98.89% | 98.89% (130,560) | **Unavailable + structural.** Stationary time at the box. OpenF1 only publishes it on 1,464 pit-visit laps (2024–2026). TracingInsights and Jolpica do not. Filter on `has_stop_duration`. Options considered: keep null + flag (chosen); drop the column from `laps_ml` and keep it only on `pit`; split those rows into a separate table. |
| `pit_source` | 90.43% | 90.45% (119,422) | **Structural:** null when `pit_this_lap = 0`. |
| `segments_sector_1/2/3` | 0.37–0.43% | 0.71–0.77% (939 / 974 / 1,019; +454 TracingInsights laps added in QA, which have no official arrays) | **Unavailable.** Official OpenF1 arrays. TracingInsights stores a compact digit string that maps digit-wise onto OpenF1 codes in some sessions, but full-array agreement across the overlap is only 34.7%, so those strings were not written into the official columns. TI also has `ms1='None'` for all 335 Baku 2025 Qualifying laps. Official livetiming would be required. Filter on `has_mini_sectors` (130,976 laps). Options: keep official arrays + flag (chosen); drop the three columns from the default table. |
| `is_deleted` | 0.13% (173) | 0.13% (173) | **Unavailable.** Comes from TracingInsights `del`. 173 OpenF1 laps have no TI row; deletion status was not assumed False. Filter on `has_deletion_status`. |
### Other tables
- **`drivers.country_code`**: **0%** null. Sources: 1,837 original OpenF1, 1,571 from another session of the same driver, 312 from Jolpica nationality.
- **`drivers.headshot_url`**: 6 remaining (Ryo Hirakawa #50 and Rafael Camara #51 have no headshot in any OpenF1 session). URLs were not invented. Filter on `has_headshot`. Options: keep null + flag (chosen); drop the column.
- **`stints`**: **0%** null, including compound. The previous 8 null compounds at 2025 Spielberg Qualifying were filled `SOFT` (`derived_session_only_compound`; 97/97 other OpenF1 stints in that session are SOFT; 12 phantom rows were later removed as orphans). `lap_end_source` is `openf1` or `derived_stint_extension`.
- **`pit.date`**: **0%** null. 227 timestamps (including all 219 Jolpica 2023 Race pits) were present in the source files as second-precision ISO strings and had been dropped by `pd.to_datetime(..., utc=True, errors='coerce')` during packing. Re-parsed with `format='ISO8601'`. `pit_duration` / `lane_duration` still null on 2,592 first-out / unpaired in-laps (**structural**). `stop_duration` null on 11,160 (**unavailable** + structural); flag `has_stop_duration`.
- **`position.date`** and **`weather.date`**: **0%** null. The same packer parse recovered 79 and 21 timestamps respectively.
- **`weather.track_temperature`**: 14 nulls. These were `0.0` readings in 11 sessions of 2026 (sessions otherwise at 13–55 °C) — an OpenF1 sensor sentinel, nulled in QA rather than kept as a real 0 °C.
- **`stints`** / **`pit`** orphans: 12 OpenF1 stint rows at 2025 Spielberg Qualifying (driver numbers 2, 3, 7, 8, 9, 11, 15, 17, 20, 21, 24, 25 — not on the entry list, no laps, each `SOFT` lap 1–1) and 1 pit row at 2026 Mexico City Qualifying for driver `236` were removed in QA (see `qa_fix_report.json`).
- **`race_control`**: **0%** null on `date`. The same parse recovered 798 timestamps and restored 56 SessionStatus rows that had been dropped after their dates became NaT and the remaining columns looked identical. High null rates on `driver_number` (80.95%), `flag` / `scope` (48.94%), `sector` (74.81%), `qualifying_phase` (80.59%), and `lap_number` (34.52%) are **structural** — track-wide messages have no driver, flag, or sector.
- **`sessions`**, **`meetings`**, **`sessions_all`**, **`car_data_sample`**, **`location_sample`**: no nulls.
Overlap checks (where OpenF1 and TracingInsights both have a value): sector times and speed traps have median absolute error **0** and ≥99.99% exact; `lap_duration` is exact on 98.6% of rows (the tail includes official vs uncorrected times and a few outliers up to 1,506 s). The sector-sum identity on complete OpenF1 rows is exact on 99.980% of 121,884 laps. Those OpenF1 values were left unchanged.
## Known caveats
- **Qualifying pit duration is usually garage dwell**, not a ~22 s race stop. TracingInsights (and OpenF1) record `pout − pin` on the out-lap. The median filled Qualifying duration is about 4 minutes (max about 29 minutes). Split models by `session_name` or `pit_source`.
- **Australia 2023 Race** (`session_key=7787`): Jolpica durations can include red-flag waiting time (46 of 65 stops; median 880 s, max 1,871 s). Filter or cap these before using `pit_duration` as a target. The other five filled 2023 races have max durations of 31–51 s.
- **2025 Baku Qualifying** (`session_key=9900`): 335 laps (131 timed) from TracingInsights. Mini-sectors are null. OpenF1 already had 122 pit rows (47 with a duration); those were kept. Timed lap *values* match the public FIA Qualifying Session Lap Times PDF to the thousandth (including Verstappen’s pole 1:41.117), but FIA lap *numbers* are not the same as FastF1/OpenF1 numbering — align by time, not by FIA `NO`. The PDF was not ingested (FIA / FOM copyright).
- **Entrants without laps** (on the OpenF1 entry list, no laps in OpenF1 or TracingInsights): 2026 Melbourne Qualifying #18 Stroll and #55 Sainz; 2026 Madring Qualifying #87 Bearman.
- Official livetiming (and therefore FastF1 against the live archive) has returned HTTP 401 without an F1TV Access login since mid-October 2026. That path was not used.
- Year-level OpenF1 filters (`/laps?year=2023`) did not work at fetch time; data was pulled per `session_key`.
- On pack, 6 Qualifying pit rows that were a null-duration unpaired in-lap colliding with a completed visit on the same `(session_key, driver_number, lap_number, source)` were dropped in favour of the timed visit. 56 `race_control` SessionStatus rows that had been dropped after a date-parse bug were restored once timestamps were re-parsed with `format='ISO8601'`.
- **2025 Las Vegas Race** (`session_key=9858`): `i2_speed` is missing on every lap in both OpenF1 and TracingInsights.
- **Red-flag lap numbering in OpenF1**: in 21 driver-sessions (2023 Mexico City Race #11; 2023 Interlagos Race; 2024 Suzuka Race, most of the grid) lap 2 has an earlier `date_start` than lap 1 and carries the red-flag stoppage (e.g. Suzuka 2024 lap 2 = 1,711 s). This is how OpenF1 numbers laps after a lap-1 red flag; values were left as published. Sort by `date_start` rather than `lap_number` if you need chronological order there.
- **Red-flag / suspended laps** keep their full elapsed `lap_duration` (up to 2,626 s) and can have very low speed-trap values (i1/i2/st down to ~25–50 km/h on 2023 Melbourne lap 56 and similar). Filter with track status from `race_control` or a per-session robust z-score.
- **Qualifying out-laps and in-laps in OpenF1 include garage / pit-lane time in `lap_duration`** (median out-lap ≈ 320 s). They are `lap_time_missing_reason == "timed"` because a time exists, so filter on `is_pit_out_lap` / `is_pit_in_lap` for pace models.
- **Deleted laps**: 5 drivers’ fastest non-deleted Qualifying lap is quicker than their official best (e.g. 2023 Jeddah #2 96.075 s vs official 128.510 s), so a few deleted laps are not flagged in `is_deleted`. All 90 pole times with Jolpica data match the dataset to the thousandth.
- **Zero-length stints**: 45 OpenF1 `stints` rows have `lap_end = lap_start − 1` (tyre changes under red flag, e.g. 2023 Melbourne Race). They never match a lap in `laps_ml`.
- **TI `tyre_age`**: on 33 laps where the stint comes from TracingInsights, `tyre_age` (TI `life − 1`) differs from `tyre_age_at_start + (lap_number − lap_start)` by a few laps. Prefer the formula when both are present.
- **TracingInsights laps not added**: 37 untimed final laps of retiring drivers in 2026 races exist in TracingInsights but not OpenF1; they were not added (no timing, no stint row).
- `date_start` from TracingInsights is about 0.18 s later than OpenF1 on overlapping laps (2025 Miami Race overlap: median 0.18 s, max 0.38 s).
- **`position_at_lap` with source `openf1_asof_forward`** is the first official snapshot *after* the lap started (median 91.5 s later), used only when no earlier snapshot exists. Do not treat it as the position at `date_start`.
## ML pitfalls (leakage)
- **`final_position` is a session-level target, repeated on every lap.** Using it as a feature in a lap-level model leaks the result. For finishing-position models use only pre-race / early-lap features (grid ≈ `position_at_lap` on lap 1, first stint compound, qualifying `final_position` of the same meeting).
- **`position_at_lap` on later laps, `pit_this_lap`, `lap_end`, `tyre_age` near stint end and `stint_number`** reveal future strategy when predicting finishing order or pit timing. Build features with lags.
- **`lap_end` and `pit_this_lap` leak the pit lap** in pit-timing / “will he pit next lap” models: `lap_end` is the stint’s final lap, known only afterwards.
- **Split by session or year, not random rows.** Laps of the same driver/session are highly correlated; random splits overstate accuracy. Train 2023–2025 / test 2026 or GroupKFold on `session_key`.
- **`pit_duration` is two different targets**: Race pit stops (~20–30 s, plus 46 Australia 2023 red-flag values up to 1,871 s) and Qualifying garage dwell (median ~4 min). Model them separately (`session_name`).
- **Source mixing**: `*_source`, `lap_source` and `final_position_source` let you drop filled values for an OpenF1-only robustness check.
## QA review (25 Nov 2026)
An independent pass re-downloaded the dataset from the Hub and checked keys, joins, value ranges, provenance and ground truth (Jolpica results / qualifying for all 182 sessions, 400 random laps against raw OpenF1 JSON). Fixes, all logged in `qa_fix_report.json` and reproducible with `scripts/qa_fixes.py`:
| Issue | Fix |
| --- | --- |
| `final_position` was the last OpenF1 position snapshot: wrong for 270 driver-sessions in 43 sessions (post-race penalties, stale Qualifying snapshots, duplicate positions in 17 sessions) | Official classification from Jolpica; 5 Qualifying sessions with duplicated Jolpica positions re-ranked from Jolpica Q times; old value kept in `final_position_openf1_snapshot` |
| 6,237 `derived_sector_identity` fills (S1 on out-laps, S3 on in-laps, red-flag laps) were garage / pit-lane time, not sectors | Reverted to null; 33 plausible fills kept |
| 2025 Miami Race laps 2–24 (all drivers) and part of lap 1/25, and 2023 Monza Race lap 51 (7 drivers) were missing from OpenF1 | 454 laps added from TracingInsights (`lap_source = tracinginsights`), joined to official stints, weather, position and pit tables |
| 14 `weather.track_temperature = 0.0` sentinels (53 laps) | Nulled in `weather`; nearest valid reading in `laps_ml` |
| 13 orphan rows (12 phantom stints, 1 pit row for driver 236) | Removed |
| `race_control` row count in this card (15,455 vs 15,511) | Corrected |
Checks that passed: no duplicate primary keys in any table; every `session_key` / `meeting_key` / `driver_number` resolves; UTC datetimes; `laps` and `laps_ml` agree on all shared columns; every `*_source` is set exactly when its value is set; `has_*` flags match nulls; `lap_time_missing_reason == "timed"` exactly when `lap_duration` is present; weather and positions within plausible ranges; all lap `date_start` inside the session window; no lap-number gaps; raw OpenF1 spot check 2,800 / 2,800 fields identical; pole times 90 / 90 exact.
## Suggested ML tasks
1. **Lap time prediction** — regress `lap_duration` on compound, `tyre_age`, circuit, team, weather, `is_pit_out_lap`, and sector or speed-trap features. Filter to `lap_time_missing_reason == "timed"` (or `lap_duration.notna()`) and usually `is_pit_out_lap == False`. A session-grouped or year holdout (train 2023–2025, test 2026) avoids leakage.
2. **Finishing position** — classify or regress `final_position` (official classification) from early-lap features only (`lap_number == 1` or the first stint) so later race state does not leak.
3. **Tyre degradation** — within a stint, how `lap_duration` changes with `tyre_age` by compound and circuit.
4. **Pit duration** — rows with `pit_this_lap == 1`, target `pit_duration`. Cap red-flag-inflated Jolpica values. Treat Qualifying and Race separately.
5. **Rain / compound choice** — `rainfall` and INTERMEDIATE/WET versus slick compounds.
## How to load
The dataset is public; no token is required to load it.
```python
from datasets import load_dataset
# Default config is laps_ml
laps_ml = load_dataset("HiddenTerps/openf1-ml-dataset", "laps_ml", split="train")
pit = load_dataset("HiddenTerps/openf1-ml-dataset", "pit", split="train")
sessions = load_dataset("HiddenTerps/openf1-ml-dataset", "sessions", split="train")
```
With pandas:
```python
import pandas as pd
from huggingface_hub import hf_hub_download
path = hf_hub_download(
"HiddenTerps/openf1-ml-dataset",
"data/laps_ml/train.parquet",
repo_type="dataset",
)
df = pd.read_parquet(path)
```
Other configs use the same pattern: `data/<config>/train.parquet`.
## Rebuild
Scripts in `scripts/` rebuild the working dump from the sources (they write to a local `openf1-dataset` folder, not this packaged layout):
```bash
python3 -m venv .venv && .venv/bin/pip install pandas pyarrow
.venv/bin/python scripts/fetch_openf1.py
.venv/bin/python scripts/fill_gaps.py
.venv/bin/python scripts/fill_gaps_tracinginsights.py
.venv/bin/python scripts/fill_nulls.py
.venv/bin/python scripts/fill_residue.py
.venv/bin/python scripts/qa_fixes.py # operates on data/<table>/train.parquet in this folder
```
`fetch_openf1.py` respects the free OpenF1 rate limit. `fill_gaps.py` uses Jolpica (custom User-Agent; unauthenticated 4 req/s, 500/hour) for 2023 Race pits. `fill_gaps_tracinginsights.py`, `fill_nulls.py` and `fill_residue.py` use public TracingInsights JSON (all 182 Race + Qualifying sessions), Jolpica driver nationalities, and documented derivations (sector identity, stint extension, peer race-start timestamps). Date packing must use `pd.to_datetime(..., format='ISO8601')` or second-precision timestamps become NaT. See `gapfill_report.json`, `nullfill_report.json`, `residue_fill_report.json` and `manifest.json` for exact counts.
## License
See [LICENSE](LICENSE). Summary:
- **OpenF1** data: educational / research / non-commercial fan use, as described by the project at [openf1.org](https://openf1.org/). Not a standard OSI license.
- **TracingInsights/2023 and 2024**: MIT.
- **TracingInsights/2025 and 2026**: Apache-2.0.
- **Jolpica**: community API; please attribute rows tagged `jolpica`.
The Hub license tag is `other` because these terms are mixed.
## Credits
- [OpenF1](https://openf1.org/) — public timing API
- [TracingInsights](https://github.com/TracingInsights) — per-session lap dumps used to fill Qualifying gaps and OpenF1-null timing, speed traps, and leftover stint fields
- [Jolpica](https://github.com/jolpica/jolpica-f1) — Ergast-compatible race pit stops and driver nationalities