A comprehensive Formula 1 data analysis and visualization tool that automatically downloads telemetry data, generates insightful analytical plots, and optionally posts them to Instagram. This project leverages the FastF1 API to provide in-depth analysis of F1 races, qualifying sessions, and practice sessions.
Project Start Date: January 2024
๐ธ Follow our analysis: @f1.data.analysis
- Intuitive event selection interface built with CustomTkinter
- Dark mode design for comfortable viewing
- Real-time progress tracking and logging
- Event Selection: Interactive GUI for selecting specific Grand Prix events from any F1 season
- Data Acquisition: Automatic download of telemetry data, lap times, and session information via FastF1 API
- Advanced Caching: Built-in FastF1 cache management for faster subsequent loads
- Retry Logic: Network error handling with automatic retry mechanism
The project generates a wide variety of analytical plots:
- ๐บ๏ธ Track map with annotated corners - Visual representation of circuit layouts
- ๐๏ธ Qualifying flying lap analysis - Detailed telemetry breakdown
- ๐ Sprint Qualifying flying lap analysis - Sprint session insights
- ๐ Race fastest lap analysis - Complete telemetry data visualization
- โฑ๏ธ Driver lap time distribution - Statistical lap time analysis
- ๐ Driver lap time scatter plots - Lap-by-lap performance visualization
- โฝ Fuel-corrected lap times (Scatterplot) - Performance adjusted for fuel load
- ๐งฎ Fuel-corrected lap times (Gaussian Processes) - Advanced ML-based analysis
- ๐ก๏ธ Driver race evolution heatmap - Race pace visualization over time
- ๐ Team pace ranking - Comparative team performance
- ๐ฒ Monte Carlo race strategy simulation - Probabilistic strategy analysis
- ๐ฏ G-G diagram (friction circle) - Longitudinal vs lateral acceleration with speed-mapped colours
- High-quality PNG image export
- Automatic caption generation for social media
- Organized file structure with timestamped outputs
- Automatic Instagram posting capability
- Custom caption generation for each plot type
- Configurable posting options
- Python 3.8 or higher
- pip package manager
- Git (for cloning the repository)
-
Clone the Repository
git clone https://github.com/bokiiiiiii/Formula-1-Data-Analysis.git cd Formula-1-Data-Analysis -
Create Virtual Environment (Recommended)
python -m venv venv # On Windows venv\Scripts\activate # On macOS/Linux source venv/bin/activate
-
Install Dependencies
pip install -r requirements.txt
-
Configure Instagram (Optional)
- If you want to use the auto-posting feature, create a
config.jsonfile - Add your Instagram credentials (refer to
config.pyfor structure)
- If you want to use the auto-posting feature, create a
-
Run FastF1 Cache Setup
# The first run will create a cache directory for faster subsequent loads python main.py
-
Launch the Application
python main.py
-
Select Your Event
- A GUI window will appear showing available F1 events
- Choose the Grand Prix you want to analyze
- Click "Start Analysis" to begin
-
View Results
- Plots will be automatically generated and saved
- Check the output folder (default:
../Pic) for images and captions
The project uses a flexible configuration system. Key settings in main.py:
YEAR = 2024 # F1 season year
SESSION_NAME = "Q" # Session(s): "FP1", "FP2", "FP3", "Q", "S", "R", or "FP1+Q+R"
FOLDER_PATH = "../Pic" # Output directory for plotsENABLE_ALL = True # Enable all plotting functions
FUNC_PARAMS = {
"plot_annotated_qualifying_flying_lap": {"enable": True, "session": "Q"},
"plot_annotated_race_fastest_lap": {"enable": True, "session": "R"},
"plot_team_pace_ranking": {"enable": True, "session": "Q"},
# ... more plot functions
}FP1,FP2,FP3- Free Practice sessionsQ- QualifyingS- Sprint QualifyingR- Race- Combined:
FP1+Q+R(processes multiple sessions)
Formula-1-Data-Analysis/
โ
โโโ main.py # Main application entry point
โโโ config.py # Configuration management
โโโ config.json # User configuration file (create manually)
โโโ logger_config.py # Logging setup
โโโ performance_monitor.py # Performance tracking utilities
โโโ retry_utils.py # Network retry logic
โโโ auto_ig_post.py # Instagram posting module
โโโ requirements.txt # Python dependencies
โโโ README.md # Project documentation
โ
โโโ plot_functions/ # Plotting modules
โ โโโ __init__.py
โ โโโ plot_runner.py # Plot execution coordinator
โ โโโ utils.py # Shared utilities
โ โ
โ โโโ annotated_qualifying_flying_lap.py
โ โโโ annotated_race_fatest_lap.py
โ โโโ annotated_sprint_qualifying_flying_lap.py
โ โโโ driver_fuel_corrected_laptimes_gaussian_processes.py
โ โโโ driver_fuel_corrected_laptimes_scatterplot.py
โ โโโ driver_laptimes_distribution.py
โ โโโ driver_laptimes_scatterplot.py
โ โโโ driver_g_g_diagram.py
โ โโโ driver_race_evolution_heatmap.py
โ โโโ monte_carlo_race_strategy.py
โ โโโ plot_track_with_annotated_corners.py
โ โโโ race_fatest_lap_telemetry_data.py
โ โโโ team_pace_ranking.py
โ
โโโ logs/ # Application logs (auto-generated)
- FastF1 (โฅ3.5): F1 data acquisition and analysis
- Matplotlib (โฅ3.8): Plotting and visualization
- Pandas (โฅ2.0): Data manipulation
- NumPy (โฅ2.0): Numerical computing
- SciPy (โฅ1.10): Scientific computing
- CustomTkinter (โฅ5.2): Modern GUI framework
- Playwright (โฅ1.40): Browser automation for Instagram
- Scikit-learn (โฅ1.3): ML algorithms (Gaussian Processes)
- Seaborn (โฅ0.13): Statistical data visualization
- Pillow (โฅ10.0): Image processing
- python-dotenv (โฅ1.0): Environment variable management
- pydantic (โฅ2.0): Data validation
See requirements.txt for complete dependency list.
This project is licensed under the MIT License - see the LICENSE file for details.