02 streamlit dashboard - VforVitorio/F1_Strat_Manager GitHub Wiki
Streamlit Dashboard
VforVitorio/F1_Strat_Manager powered by Devin
- Overview
- System Architecture
- Installation and Setup
- Streamlit Dashboard
- Strategy Recommendations View
- Gap Analysis View
- Radio Analysis View
- Time Predictions View
- Strategy Chat Interface
- Machine Learning Models
- Lap Time Prediction
- Tire Degradation Modeling
- Vision-based Gap Calculation
- NLP Pipeline
- Radio Transcription
- Sentiment and Intent Analysis
- Named Entity Recognition
- Expert System
- Degradation Rules
- Gap Analysis Rules
- Radio Message Rules
- Integrated Rule Engine
- Developer Guide
- API Reference
- Integration Guide
Streamlit Dashboard
Relevant source files
- scripts/app/app.py
- scripts/app/components/degradation_view.py
- scripts/app/components/gap_analysis_view.py
- scripts/app/components/overview_view.py
- scripts/app/components/team_radio_view.py
- scripts/app/utils/processing.py
- scripts/app/utils/visualization.py The Streamlit Dashboard serves as the primary user interface for the F1 Strategy Manager system. It provides an interactive environment where race engineers can analyze data, visualize insights, and receive strategic recommendations. This central hub integrates output from various subsystems including tire degradation models, gap analysis, lap time predictions, and team radio analysis. For information about the expert system generating recommendations, see Expert System, and for details on the machine learning models powering the predictions, see Machine Learning Models.
Dashboard Architecture
The dashboard is built with Streamlit, a Python framework for creating data applications. It follows a modular design with separate components for each analysis view, connected through a central navigation system.
Navigation and User Interface
The dashboard provides a consistent navigation structure through a sidebar that allows users to switch between different analysis views. The main application file handles the routing logic and maintains the application state.
Main Navigation Structure
The navigation is implemented as a sidebar with radio buttons for different views:
- Overview
- Tire Analysis
- Gap Analysis
- Lap Time Predictions
- Team Radio Analysis
- Strategy Recommendations
- Competitive Analysis
- Vision Gap Extraction
- Strategy Chat
- Export Strategy Report
Data Selection
The sidebar also contains controls for data selection, allowing users to:
- View race information (currently fixed to "Spain 2023")
- Select a driver to analyze (from available drivers in the dataset) When a new driver is selected, the relevant data is reloaded and processed for the selected driver.
Data Flow
The dashboard implements a data flow pattern that loads, processes, and visualizes race data and strategic recommendations. Data is cached in the Streamlit session state to improve performance when navigating between views.
Main View Components
The dashboard consists of several key view components, each focusing on a specific aspect of race strategy analysis.
Overview View
The Overview view provides a high-level summary of the race performance for the selected driver. It includes:
- Key metrics (average degradation, pit stops, final position)
- Lap time evolution chart with tire compound visualization
- Multi-driver lap time comparison
Tire Analysis View
The Tire Analysis view focuses on tire performance and degradation throughout the race. It uses a tabbed interface to organize different analyses:
- Degradation Rate Analysis: Shows how quickly tire performance degrades over time
- Fuel-Adjusted Analysis: Compares raw vs. fuel-adjusted tire degradation
- Speed Comparison: Analyzes how sector speeds evolve as tires age
The view uses specialized visualization functions such as
st_plot_degradation_rate()
,st_plot_regular_vs_adjusted_degradation()
, andst_plot_speed_vs_tire_age()
.
Gap Analysis View
The Gap Analysis view examines the gaps between cars throughout the race. It includes:
- Gap Evolution: Shows how gaps to cars ahead and behind evolved during the race
- Undercut Opportunities: Visualizes windows where undercut or overcut strategies were possible
- Gap Consistency: Displays how consistently gaps were maintained over multiple laps
- Strategic Insights: Summarizes strategic opportunities identified from gap analysis This view helps race engineers identify strategic opportunities based on car position.
Lap Time Predictions View
This view displays predictions for future lap times based on machine learning models, helping teams anticipate performance changes. It provides:
- Visualization of predicted lap times
- Comparison between actual and predicted performance
- Fuel-adjusted lap time analysis The predictions are generated using XGBoost models trained on historical race data.
Team Radio Analysis View
This view analyzes team radio communications for strategic insights, including:
- Radio-based strategic recommendations
- Radio message sentiment analysis
- Key communications that might impact race strategy The system identifies radio messages that could indicate important events (weather changes, strategic decisions by competitors, etc.).
Strategy Recommendations View
This central view displays AI-generated strategy recommendations from the expert system. Engineers can review and filter recommendations based on:
- Confidence levels
- Action types
- Strategic urgency
Strategy Chat Interface
A unique feature allowing engineers to ask natural language questions about race strategy. This LLM-powered interface:
- Provides conversational access to strategy insights
- Explains reasoning behind recommendations
- Allows exploration of alternative strategies
Data Visualization
The dashboard heavily uses interactive visualizations to present complex race data in an intuitive format. These visualizations are implemented using Plotly and are rendered through specialized functions in the visualization.py
file.
Key Visualization Functions
Function | Purpose | Source |
---|---|---|
st_plot_degradation_rate() |
Visualizes tire degradation rates | visualization.py227-257 |
st_plot_regular_vs_adjusted_degradation() |
Compares raw vs. fuel-adjusted degradation | visualization.py76-158 |
st_plot_gap_evolution() |
Shows gap evolution over time | visualization.py260-310 |
st_plot_undercut_opportunities() |
Highlights strategic windows | visualization.py313-362 |
st_plot_gap_consistency() |
Visualizes gap consistency metrics | visualization.py365-399 |
st_plot_fuel_adjusted_degradation() |
Shows fuel-adjusted degradation data | visualization.py161-191 |
Each visualization function takes processed data and creates interactive Plotly charts that engineers can explore within the dashboard. |
Integration with Other Subsystems
The dashboard integrates with multiple subsystems to provide a comprehensive strategy management platform:
Performance Considerations
The dashboard implements several performance optimizations:
- Session State Caching: Data is loaded once and cached in session state to avoid redundant processing
- Selective Data Loading: Only data for the selected driver is processed when possible
- Error Handling: Robust error handling prevents dashboard crashes when data is missing or models fail
Key Files and Functions
The dashboard is implemented across several key files:
File | Purpose |
---|---|
app.py |
Main application entry point and routing logic |
utils/processing.py |
Data processing functions |
utils/visualization.py |
Visualization functions |
utils/data_loader.py |
Data loading functions |
components/*.py |
Individual view components |
The modular structure allows for easy maintenance and extension of dashboard functionality. |
Conclusion
The Streamlit Dashboard provides a comprehensive interface for the F1 Strategy Manager system, integrating data from various sources and presenting it through intuitive visualizations. The dashboard connects ML models, the expert system, and raw data to deliver actionable insights for race engineers. Future enhancements may include additional views, more advanced visualizations, and deeper integration with live data sources during races.
On this page
- Streamlit Dashboard
- Dashboard Architecture
- Navigation and User Interface
- Main Navigation Structure
- Data Selection
- Data Flow
- Main View Components
- Overview View
- Tire Analysis View
- Gap Analysis View
- Lap Time Predictions View
- Team Radio Analysis View
- Strategy Recommendations View
- Strategy Chat Interface
- Data Visualization
- Key Visualization Functions
- Integration with Other Subsystems
- Performance Considerations
- Key Files and Functions
- Conclusion