Zing Forum

Reading

F1 PitWall: Building an F1 Data Engineering and Strategy Analysis Platform with Python and Machine Learning

A desktop application for F1 racing data engineering and strategy prediction based on PySide6 and FastF1 API, integrating random forest tire degradation prediction, Monte Carlo race simulation, and real-time telemetry analysis to simulate the decision-making environment of real F1 teams.

Formula 1F1PythonPySide6Machine LearningRandom ForestFastF1TelemetryMonte CarloData Engineering
Published 2026-06-13 04:45Recent activity 2026-06-13 04:49Estimated read 10 min
F1 PitWall: Building an F1 Data Engineering and Strategy Analysis Platform with Python and Machine Learning
1

Section 01

F1 PitWall Project Guide: Building an F1 Data Engineering and Strategy Analysis Platform with Python + ML

F1 PitWall is a desktop-level data engineering and strategy analysis platform designed for F1 enthusiasts and data engineers. Built with Python and PySide6 for its graphical interface, it fetches real race telemetry data via the FastF1 API, integrating random forest tire degradation prediction, Monte Carlo race simulation, and real-time telemetry analysis. Its goal is to simulate the decision-making environment of a real F1 team's PitWall and convert raw data into actionable racing intelligence.

2

Section 02

Project Background and Overview

Original Author and Source

Project Overview

F1 PitWall is positioned as a desktop-level data engineering and strategy analysis platform targeting F1 enthusiasts and data engineers. Its design goal is to simulate the decision-making environment of a real F1 team's PitWall and convert raw data into actionable racing intelligence.

3

Section 03

Technical Architecture and Implementation Methods

Technical Architecture Analysis

Frontend Interface

  • Framework: PySide6 (Qt for Python)
  • Chart Engine: Matplotlib (embedded in Qt's FigureCanvas)
  • UI Design: Dark theme, imitating F1's official visual style with primary colors red (#e10600) and blue (#00aeef)
  • Tab Structure: Three core tabs: Race Summary, Telemetry Analysis, Strategy Prediction

Data Layer

  • Data Source: FastF1 library (encapsulates Ergast API and F1 Live Timing data)
  • Caching Mechanism: Local file system cache (cache_f1 directory)
  • Data Processing: Pandas (cleaning and transformation), NumPy (numerical computation)

Machine Learning Module

  • Model Type: Random Forest Regression
  • Feature Engineering: Tyre Life (TyreLife), Tyre Type Encoding (Compound_Encoded)
  • Training Data: Clean lap data from completed races of the current or previous year
  • Model Persistence: Save models and label encoders using joblib
  • Prediction Output: Predict lap time given tyre type and number of laps used

Track Historical Data Module

Implements an intelligent data fallback mechanism: Prioritize fetching target year data → fallback to previous year → extract key parameters → use default values (if historical data is unavailable)

4

Section 04

Detailed Explanation of Core Function Modules

Core Function Modules

1. Race Summary Analysis

  • Race Results Table: Displays ranking, grid position, position changes, tyre strategy
  • Position Evolution Chart: Time-series visualization of driver position changes
  • Lap Time Distribution Box Plot: Rhythm stability analysis based on clean laps
  • Pit Stop Time Analysis: Calculation of total pit lane time
  • Top Speed Data: Record of maximum speed at speed measurement points

2. Telemetry Data Analysis

  • Single Lap Telemetry: Complete telemetry data (speed, throttle, brake, etc.) for a specific driver's lap
  • Two-Car Comparison: Direct lap time comparison between two drivers (aligned by distance dimension)
  • Data Downsampling: Take 1 sample every 3 points to optimize rendering

3. Strategy and Prediction

  • Strategy Simulator: Calculate cumulative time for one-stop (PlanA) and two-stop (PlanB) strategies, recommend optimal plan
  • Monte Carlo Race Prediction: Predict results considering variables like driver strength, tyre degradation, random fluctuations, safety car probability, pit stop errors, and retirement simulation
5

Section 05

Highlights of Code Structure

Highlights of Code Structure

Multi-threaded Design

All time-consuming operations are encapsulated in QThread subclasses (e.g., SummaryWorker, TelemetryWorker), ensuring UI responsiveness and using signal mechanisms for thread communication

Dynamic UI Updates

  • Filter corresponding tracks and drivers after selecting a year
  • Detect Sprint format and update session options after selecting a track
  • Use the filtrar_por_ano method uniformly to handle linkage logic

Error Handling and Degradation Strategy

  • Automatically try historical data if API call fails
  • Return friendly prompt if ML model is not trained
  • Random factors have reasonable fallback values
  • Application does not crash if chart rendering fails
6

Section 06

Application Scenarios and Tech Stack Summary

Practical Application Scenarios

  • F1 Data Analysts: Verify official data consistency, analyze driving styles, build custom prediction models
  • Racing Strategists: Understand tyre strategy differences, pit window impacts, safety car/weather interference on strategies
  • ML Learners: Practice feature engineering, model integration, joblib model management

Tech Stack Summary

Category Technology Purpose
GUI Framework PySide6 >=6.5.0 Desktop application interface
Data Science NumPy, Pandas Data processing and computation
Machine Learning scikit-learn, joblib Tyre degradation prediction model
F1 Data fastf1 >=3.0.0 Official telemetry data API
Charts matplotlib >=3.7.0 Data visualization
Report Generation reportlab >=4.0.0 PDF export
7

Section 07

Expansion Possibilities and Project Summary

Expansion Possibilities

  1. Real-time data access: Expand into a real-time monitoring tool during races
  2. More ML models: Try XGBoost, LSTM to improve prediction accuracy
  3. Visualization enhancement: Integrate Plotly/PyQtGraph for interactive charts
  4. Data export: Expand to Excel, CSV, etc.
  5. Web version: Use PySide6 WebAssembly or rewrite as a web application

Project Summary

F1 PitWall is an open-source project that organically combines sports data analysis and machine learning. It provides a complete workflow for F1 data acquisition, analysis, and visualization, demonstrating the practical application of ML models through Monte Carlo simulation and random forest prediction. For data engineers, F1 enthusiasts, and ML learners, it has both practical value and learning significance.