A machine learning-powered application that predicts Formula 1 race results using historical data, driver performance metrics, and weather conditions.
- Multi-Race Support: Predict results for any race on the F1 calendar
- Real-time Weather Integration: Incorporates weather forecasts using OpenWeatherMap API
- Driver Performance Analytics: Uses historical lap times, qualifying performance, and team data
- Visual Predictions: Interactive charts showing predicted results and time gaps
- Machine Learning Model: Gradient boosting algorithm for accurate predictions
- Track-Specific Analysis: Different parameters based on circuit characteristics
graph TD
A[User Interface - Streamlit] --> B[Main Application - app.py]
B --> C[Data Loader Module]
B --> D[Model Module]
C --> E[FastF1 API]
C --> F[OpenWeatherMap API]
D --> G[Scikit-learn Models]
C --> H[Configuration]
H --> I[Track Data]
H --> J[Driver Data]
H --> K[Race Schedule]
E --> M[Historical Race Data]
F --> N[Weather Data]
G --> O[Predicted Results]
O --> A
I --> C
J --> C
K --> B
%% High contrast theme-aware colors with visible arrows
classDef uiNode fill:#4fc3f7,stroke:#01579b,stroke-width:2px,color:#000
classDef apiNode fill:#81c784,stroke:#1b5e20,stroke-width:2px,color:#000
classDef weatherNode fill:#ffb74d,stroke:#e65100,stroke-width:2px,color:#000
classDef modelNode fill:#ba68c8,stroke:#4a148c,stroke-width:2px,color:#000
classDef resultNode fill:#64b5f6,stroke:#0d47a1,stroke-width:2px,color:#000
classDef defaultNode fill:#e0e0e0,stroke:#424242,stroke-width:2px,color:#000
%% Apply classes
class A uiNode
class E apiNode
class F weatherNode
class G modelNode
class O resultNode
class B,C,D,H,I,J,K,M,N defaultNode
%% Style for arrows to be visible in both themes
linkStyle default stroke:#888,stroke-width:2px
- Python 3.8+
- Git
- Clone the repository:
git clone https://github.com/BLShaw/f1-predictor.git
cd f1-predictor- Create a virtual environment (recommended):
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install required packages:
pip install -r requirements.txt- Set up your OpenWeatherMap API key in
src/config.pyor in UI:
WEATHER_API_KEY = "your_api_key_here"Run the Streamlit application:
streamlit run app.pyThe application will open in your default browser where you can:
- Select a Race: Choose from any race on the 2025 F1 calendar
- Configure Parameters: Adjust model settings in the sidebar
- Run Prediction: Generate race predictions with one click
- Analyze Results: View predictions, performance metrics, and visualizations
- Race Selection Panel: Choose any race from the schedule
- Configuration Panel: Adjust model parameters
- Data Loading Section: Shows real-time loading status
- Prediction Dashboard: View predicted results and insights
- Visualization Gallery: Charts for performance analysis
- F1 Timing Data: FastF1 library for historical lap times and sector data
- Weather Data: OpenWeatherMap API for weather conditions
- Driver/Team Data: F1 records and statistics
- Qualifying Performance: Driver's qualifying time for the selected race
- Historical Data: Average lap times and sector performance from previous seasons
- Team Performance: Current season team points and performance metrics
- Weather Conditions: Rain probability and temperature forecasts
- Track Characteristics: Position changes specific to the selected track
f1-race-predictor/
├── README.md # Project documentation
├── app.py # Main Streamlit application entry point
├── requirements.txt # Python dependencies
├── f1_cache/ # FastF1 data cache
└── src/ # Source code modules
├── __init__.py # Python package initialization
├── config.py # Configuration and constants
├── data_loader.py # Data loading and preprocessing
└── model.py # ML model implementation
- Streamlit-based UI
- Race selection interface
- Visualization dashboard
- Model execution orchestration
- API keys and credentials
- Track coordinates and weather data
- Driver and team mappings
- Race schedule information
- Model parameters and constants
- F1 session data loading using FastF1
- Weather data fetching from OpenWeatherMap
- Data processing and aggregation
- Track-specific data adjustments
- Gradient Boosting Regressor implementation
- Feature engineering
- Model training and prediction
- Performance metrics calculation
The predictor uses several key factors:
- Driver Performance: Historical lap times and sector performance
- Qualifying Data: Expected qualifying performance for the race
- Team Metrics: Team performance based on current season points
- Weather Impact: Rain probability and temperature effects
- Track Characteristics: Circuit-specific position change patterns
We welcome contributions! Here's how you can help:
- Fork the Repository: Create your own copy to experiment
- Create Feature Branch:
git checkout -b feature/amazing-feature - Commit Changes:
git commit -m 'Add some amazing feature' - Push to Branch:
git push origin feature/amazing-feature - Open Pull Request: Submit for review
This application is for educational and entertainment purposes only. Predictions are based on historical data and statistical models, and do not represent actual race outcomes.
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter issues or have questions, please:
- Check the Issues section
- Open a new issue if needed
- Provide detailed information about the problem
- FastF1 library for F1 data access
- OpenWeatherMap for weather data
- Formula 1 for making this sport amazing
- Streamlit for the web interface framework