https://github.com/aini9027/f1-analytics-portfolio
Formula 1 Race Strategy Analytics โ End-to-End Data Analytics Project (SQL, Python, Power BI)
https://github.com/aini9027/f1-analytics-portfolio
dashboard data-analytics ergast etl fastf1 formula1 kaggle portfolio-project postgres powerbi python sql sqlite streamlit tableau visualization
Last synced: 2 months ago
JSON representation
Formula 1 Race Strategy Analytics โ End-to-End Data Analytics Project (SQL, Python, Power BI)
- Host: GitHub
- URL: https://github.com/aini9027/f1-analytics-portfolio
- Owner: aini9027
- Created: 2025-11-07T16:45:48.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-11-07T21:02:10.000Z (8 months ago)
- Last Synced: 2025-11-07T22:24:44.432Z (8 months ago)
- Topics: dashboard, data-analytics, ergast, etl, fastf1, formula1, kaggle, portfolio-project, postgres, powerbi, python, sql, sqlite, streamlit, tableau, visualization
- Language: Jupyter Notebook
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐๏ธ Formula 1 Race Strategy Analytics
**End-to-End Data Analytics Project (SQL | Python | Power BI | Tableau | FastF1)**
## ๐ฏ Project Goal
Analyze Formula 1 race, qualifying, and lap data to uncover **how driver performance, team strategies, and pit-stop timing influence race outcomes** โ and present findings through **clean insights, visuals, and dashboards**.
## ๐ก Objectives
- Clean, structure, and integrate multi-source F1 datasets (Ergast API, Kaggle CSVs, FastF1).
- Perform SQL-based exploratory analysis on races, drivers, constructors, and circuits.
- Visualize **driver consistency, qualifying vs. race performance, pit-stop strategy**, and telemetry insights.
- Provide actionable insights for a โteam principalโ or strategist.
- Deliver a professional analytics case study with code, queries, visuals, and reports.
## ๐งฉ Key Questions Explored
1. Which drivers and teams are most consistent across seasons?
2. How strong is the correlation between qualifying and final race position?
3. How much time is gained or lost through pit-stop strategy?
4. Which circuits favor which teams or drivers?
5. What is the impact of pitting under Safety Car vs. green flag conditions?
## ๐๏ธ Project Structure
> All analysis code is available inside the `notebooks/` directory, with each step of the workflow clearly documented and reproducible.
```
f1-analytics-portfolio/
โ
โโ data/ # CSVs or API extracts (drivers, races, results, telemetry)
โโ notebooks/
โ โโ 01_data_import_and_cleaning.ipynb
โ โโ 02_exploratory_analysis.ipynb
โ โโ 03_fastf1_silverstone_2023_analysis.ipynb
โ
โโ sql/
โ โโ schema.sql
โ โโ queries.sql
โ
โโ dashboard/
โ โโ power_bi/
โ โโ powerbi_layout.md
โ
โโ reports/
โ โโ executive_summary.md
โ โโ slide_deck.pdf
โ
โโ PROJECT_LOG.md
โโ README.md
โโ requirements.txt
```
## ๐ ๏ธ Tech Stack
| Category | Tools / Libraries |
|-----------|-------------------|
| Data Ingestion | Python (pandas, requests), FastF1, Ergast API |
| Database | SQLite (demo), PostgreSQL (future) |
| Analysis | SQL, pandas, numpy |
| Visualization | Power BI, Tableau, Matplotlib, Plotly |
| Reporting | Markdown, PDF, PowerPoint |
## ๐ Data Sources
- **Ergast API** โ historical results, qualifying, pit stops, lap times
- **FastF1 Library** โ timing, tyre, stint, and telemetry data
- **Kaggle Datasets** โ precompiled CSVs for offline use
### ๐ Processed Data (Generated)
- `sector_deltas_ver_ham.csv`
- `lap_deltas_ver_ham.csv`
- `racecraft_laps_ver_ham.csv`
- `racecraft_summary_ver_ham.csv`
## ๐ Silverstone 2023 โ Tyre & Stint Insights (VER vs HAM)
This project includes targeted analysis of the **2023 British Grand Prix (Silverstone)**, comparing **Max Verstappen (VER)** and **Lewis Hamilton (HAM)**.
### ๐น Tyre Compound Pace
- Computed average & median lap times by tyre compound (Soft / Medium / Hard)
- Visual comparison of compound performance for both drivers
- VER showed superior average pace across tyre types
### ๐น Stint-Level Performance
- Boxplots reveal lap-time distribution per stint
- VER displayed lower variance โ higher consistency
- HAM exhibited greater fluctuation indicating tyre drop or traffic periods
### ๐น Why This Matters
- Shows relative tyre management ability
- Helps quantify race pace consistency
- Forms the foundation for the upcoming **Driver Scouting Scorecard**
## ๐ธ Sample Visuals from the Analysis
Below are selected visuals from the Silverstone 2023 (VER vs HAM) race analysis to demonstrate pace, strategy, and driver performance differences.
### ๐ Position Evolution โ VER vs HAM (Silverstone 2023)
### ๐ฆ Sector Delta Comparison (HAM โ VER)
### ๐ฅ Lap Time Delta (HAM โ VER)
### ๐จ Tyre Compound Pace (Average Lap Times)
### ๐ฉ Stint Consistency Boxplots
## ๐ก Telemetry Insights โ Silverstone 2023 (VER vs HAM)
Using FastF1 telemetry, the project compares **Max Verstappen and Lewis Hamilton** on a selected race lap at Silverstone 2023.
### ๐น Speed Trace Overlay
- Shows how VER and HAM differ in **corner entry, mid-corner, and exit speeds**.
- Highlights where one driver is more confident on turn-in or maintains higher minimum speed.
### ๐น Speed Delta by Distance (HAM โ VER)
- Positive delta โ HAM faster at that point on track
- Negative delta โ VER faster
- Allows **corner-by-corner performance comparison** and ties together:
- Car setup differences
- Tyre state
- Driving style
These telemetry insights complement the lap/sector delta analysis and support a **driver scouting and race engineering perspective**, not just pure statistics.
๐ก How to Read F1 Telemetry Plots (Engineer-Level Guide)
Understanding telemetry is essential in Formula 1 because it reveals where and why one driver is faster than another.
This project uses FastF1 telemetry data (speed, distance, sectors) to compare Max Verstappen (VER) and Lewis Hamilton (HAM) during the 2023 British Grand Prix.
This section explains how to interpret the telemetry plots included in this repository so that even non-technical readers can follow the engineering analysis.
๐๏ธ 1. Speed Trace Overlay (Speed vs Distance)
The speed trace shows how a driver brakes, corners, and accelerates through the lap.
๐ What to look for
A. Braking Zones (sharp downward slopes)
A steep drop = hard or late braking
A smooth drop = earlier or more controlled braking
Example interpretation:
If HAMโs curve drops later โ HAM brakes later / more aggressively
If VERโs drop is smoother โ VER manages the entry more progressively
B. Apex Speeds (lowest point in the curve)
This shows mid-corner grip and rotation.
Example interpretation:
If VERโs minimum speeds are higher โ VER carries more mid-corner speed
If HAMโs line sits higher at certain corners โ Mercedes stronger in that section
C. Corner Exit (where the curve rises after the apex)
Shows traction and throttle application.
Example interpretation:
VERโs trace rising earlier โ better traction or earlier throttle
HAM accelerating sooner โ stronger exit grip or deployment
D. Straights (flat or gently rising areas)
Peak speeds indicate top-end performance.
Example interpretation:
Higher peak speed = lower drag / better ERS
HAM faster on straights โ Mercedes aero efficiency
VER faster โ Red Bullโs lower drag philosophy
๐ 2. Speed Delta Plot (HAM โ VER)
The delta plot shows directly which driver is faster at each part of the track.
Positive delta (above zero) โ HAM faster
Negative delta (below zero) โ VER faster
๐ What patterns reveal
A. Time Gain / Loss
Rising delta โ HAM gaining
Falling delta โ VER gaining
B. Corner Characteristics
Deep dips at corner exits โ VER traction advantage
Sharp spikes at braking zones โ HAM braking confidence
Flat positive regions โ HAM straight-line advantage
Sustained negative regions โ VER corner-to-corner momentum
๐ง Why This Analysis Matters
Telemetry reveals the exact reason behind lap time differences:
Where does each driver gain or lose time?
Is the advantage from braking, apex speed, or traction?
Are the differences caused by setup, driving style, or tyre condition?
This type of analysis mirrors how F1 teams evaluate:
Driver performance
Car balance
Setup options
Strategy decisions
Including telemetry in your portfolio demonstrates race engineering-level analytical thinking, far beyond basic data visualization.
๐ Coming Soon
Future telemetry enhancements planned for this project:
Corner labels (Turn 1โ18 overlays)
Throttle & brake traces
Gear usage comparison
ERS deployment mapping
Driver performance scoring framework
## ๐ฅ๏ธ Deliverables
- ๐งฎ Clean database (`data/f1.db`)
- ๐๏ธ SQL queries and analytical scripts
- ๐ Jupyter Notebooks (cleaning, EDA, FastF1 analysis)
- ๐ Power BI dashboard layout (`dashboard/powerbi_layout.md`)
- ๐งพ Executive summary & slide deck
## ๐ Exploratory Data Analysis (SQL-First)
**Update โ November 2025**
The SQL-focused notebook (`02_exploratory_analysis.ipynb`) includes:
- Wins per driver
- Average points per driver
- Positions gained (grid vs finish)
- Pit-stop durations by team
- Grid vs finish correlation (Pearson & Spearman)
- Circuit performance summaries
- Clean, reproducible Matplotlib charts
This demonstrates strong **SQL analytical thinking** and supports future dashboard integration.
## ๐ง Example Insights
> - **Early pit-stop advantage**: Drivers pitting before lap 15 gained +0.7 positions on average.
> - **Qualifying โ Race correlation**: r = 0.68 โ grid position remains decisive.
> - **Consistency outliers**: Midfield drivers occasionally show top-tier consistency across seasons.
## ๐ How to Use
```bash
git clone https://github.com/ammarhaider/f1-analytics-portfolio.git
cd f1-analytics-portfolio
```
1. Place Kaggle/Ergast files into `/data`
2. Run the cleaning notebook
3. Load the database into SQLite/PostgreSQL
4. Run SQL queries
5. Open the Power BI / Tableau dashboard
## ๐ Latest Updates
- Added interactive notebooks (Nov 2025)
- Added Silverstone FastF1 analysis
- Included example SQLite database
- Added Power BI layout brief
### ๐ Update โ Sector & Lap Delta Analysis Added (24 Nov 2025)
The project now includes detailed **sector-by-sector** and **lap delta** analysis for the 2023 British Grand Prix (Silverstone), comparing **Max Verstappen (VER)** and **Lewis Hamilton (HAM)**.
**Whatโs new:**
- Extracted and cleaned sector timing data (S1, S2, S3) using FastF1.
- Computed per-lap sector deltas (HAM โ VER) to show where each driver gained or lost time.
- Built a full-race lap delta curve to visualize underlying race pace differences.
- Added visualizations for sector deltas and lap deltas.
- Exported outputs (`sector_deltas_ver_ham.csv`, `lap_deltas_ver_ham.csv`) for integration into SQL and Power BI.
**Why it matters:**
This analysis highlights *where* driver and car performance differs โ high-speed sections, technical middle sector, braking zones, and traction exits.
This forms the basis for upcoming telemetry overlays and the driver scoring model.
---
## ๐ Additional Documentation
- ๐ **[ABOUT.md](ABOUT.md)**
Detailed overview of the project structure, goals, analytics workflow, and long-term roadmap.
- ๐ **[CONTRIBUTING.md](CONTRIBUTING.md)**
Guidelines for setting up the environment, coding standards, naming conventions, and how to contribute to the project.
- ๐ **[LICENSE](LICENSE)**
MIT License โ permissions, usage rights, and limitations for this project.
For a step-by-step build history, see:
- ๐ **[PROJECT_LOG.md](PROJECT_LOG.md)**
---
## ๐
Future Enhancements
- Predictive modeling (finishing position regression)
- Weather & Safety Car race simulation
- Multi-season comparative dashboards
- Streamlit app for interactive analysis
## ๐จโ๐ป Author
**Ammar Haider**
Data Analytics Enthusiast | F1 Fan | Portfolio Builder