Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -523,32 +523,7 @@ def main():
|
|
| 523 |
# Create and display chart
|
| 524 |
fig, violations = create_severity_violation_chart(df, selected_age)
|
| 525 |
|
| 526 |
-
|
| 527 |
-
# # clicked_points = plotly_events(fig, click_event=True, override_height=600)
|
| 528 |
-
|
| 529 |
-
# if clicked_points:
|
| 530 |
-
# selected_violation = clicked_points[0]['x']
|
| 531 |
-
# if selected_violation != st.session_state['selected_violation']:
|
| 532 |
-
# st.session_state['selected_violation'] = selected_violation
|
| 533 |
-
|
| 534 |
-
# # If a violation is selected, display the pie chart --> added for part3 (interactive pie chart)
|
| 535 |
-
# if st.session_state['selected_violation']:
|
| 536 |
-
# # pie_chart = create_interactive_pie_chart(violations, st.session_state['selected_violation'])
|
| 537 |
-
# pie_chart = create_interactive_pie_chart(violations, st.session_state['selected_violation'], selected_age) # dynamically update pie chart's title
|
| 538 |
-
# st.plotly_chart(pie_chart, use_container_width=True)
|
| 539 |
-
|
| 540 |
-
# # Display statistics
|
| 541 |
-
# if selected_age == 'All Ages':
|
| 542 |
-
# total_incidents = len(df)
|
| 543 |
-
# else:
|
| 544 |
-
# total_incidents = len(df[
|
| 545 |
-
# (df['Age_Group_Drv1'] == selected_age) |
|
| 546 |
-
# (df['Age_Group_Drv2'] == selected_age)
|
| 547 |
-
# ])
|
| 548 |
-
|
| 549 |
-
|
| 550 |
-
with desc_col:
|
| 551 |
-
clicked_points = plotly_events(fig, click_event=True, override_height=600, override_width="100%")
|
| 552 |
# clicked_points = plotly_events(fig, click_event=True, override_height=600)
|
| 553 |
|
| 554 |
if clicked_points:
|
|
@@ -570,36 +545,37 @@ def main():
|
|
| 570 |
(df['Age_Group_Drv1'] == selected_age) |
|
| 571 |
(df['Age_Group_Drv2'] == selected_age)
|
| 572 |
])
|
| 573 |
-
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
|
| 577 |
-
|
| 578 |
-
|
| 579 |
-
|
| 580 |
-
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
|
| 585 |
-
|
| 586 |
-
|
| 587 |
-
|
| 588 |
-
|
| 589 |
-
|
| 590 |
-
|
| 591 |
-
|
| 592 |
-
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
|
| 602 |
-
|
|
|
|
| 603 |
|
| 604 |
with tab3:
|
| 605 |
# Dropdown for category selection
|
|
|
|
| 523 |
# Create and display chart
|
| 524 |
fig, violations = create_severity_violation_chart(df, selected_age)
|
| 525 |
|
| 526 |
+
clicked_points = plotly_events(fig, click_event=True, override_height=600, override_width="50%")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 527 |
# clicked_points = plotly_events(fig, click_event=True, override_height=600)
|
| 528 |
|
| 529 |
if clicked_points:
|
|
|
|
| 545 |
(df['Age_Group_Drv1'] == selected_age) |
|
| 546 |
(df['Age_Group_Drv2'] == selected_age)
|
| 547 |
])
|
| 548 |
+
|
| 549 |
+
|
| 550 |
+
with desc_col:
|
| 551 |
+
st.markdown("""
|
| 552 |
+
# Severity of Violations Across Age Groups
|
| 553 |
+
This section provides an interactive visualization of **crash severities** linked to specific violation types, segmented by driver age groups. It enables a comprehensive analysis of how **age influences crash severity and violation trends**. The visualization is linked to an **interactive pie chart** that updates when a specific bar is selected, displaying the detailed distribution of the selected violation type based on the selected age group.
|
| 554 |
+
---
|
| 555 |
+
## **Key Features**
|
| 556 |
+
### 1. **Age Group Analysis**
|
| 557 |
+
- Select specific age groups (e.g., "16-25", "65+") or analyze all ages to explore correlations between:
|
| 558 |
+
- Age
|
| 559 |
+
- Violation type
|
| 560 |
+
- Crash severity
|
| 561 |
+
- Understand how different age groups are involved in various types of violations.
|
| 562 |
+
### 2. **Violation Breakdown**
|
| 563 |
+
- Examine the most frequent violations contributing to traffic accidents for each age group.
|
| 564 |
+
- View detailed statistics showing the distribution of violation types.
|
| 565 |
+
### 3. **Understanding Severity Level**
|
| 566 |
+
- Identify the proportion of severity levels for a specific violation type based on different age groups.
|
| 567 |
+
- Investigate detailed severity patterns for each violation type across age groups.
|
| 568 |
+
---
|
| 569 |
+
## **Insights**
|
| 570 |
+
- **Identifies High-Risk Behaviors:**
|
| 571 |
+
- Highlights risky behaviors such as reckless driving in younger drivers or impaired driving in older groups.
|
| 572 |
+
|
| 573 |
+
- **Highlights Severity Associations:**
|
| 574 |
+
- Shows which violations are associated with more severe outcomes, aiding targeted safety interventions and public awareness campaigns.
|
| 575 |
+
- **Supports Data-Driven Decision Making:**
|
| 576 |
+
- Provides insights for designing **age-specific traffic safety programs**.
|
| 577 |
+
---
|
| 578 |
+
""")
|
| 579 |
|
| 580 |
with tab3:
|
| 581 |
# Dropdown for category selection
|