Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1687,7 +1687,7 @@ with col_insights:
|
|
| 1687 |
if col_speed and col_speed in df.columns:
|
| 1688 |
|
| 1689 |
# --- Threshold FIX > 20 km/h ---
|
| 1690 |
-
high_speed_threshold = 20
|
| 1691 |
|
| 1692 |
# --- Filter High-Speed Fatigue ---
|
| 1693 |
high_speed_fatigue = df[df[col_speed] > high_speed_threshold]
|
|
@@ -1695,32 +1695,39 @@ if col_speed and col_speed in df.columns:
|
|
| 1695 |
# --- Persentase ---
|
| 1696 |
high_speed_pct = (len(high_speed_fatigue) / len(df) * 100) if len(df) > 0 else 0
|
| 1697 |
|
| 1698 |
-
# ---
|
| 1699 |
-
st.markdown(f"###
|
| 1700 |
|
| 1701 |
-
# ---
|
| 1702 |
-
st.
|
| 1703 |
-
|
| 1704 |
-
|
| 1705 |
-
|
| 1706 |
-
|
| 1707 |
-
|
| 1708 |
-
|
| 1709 |
-
|
| 1710 |
-
|
| 1711 |
-
|
| 1712 |
-
|
| 1713 |
-
|
| 1714 |
-
|
| 1715 |
-
|
| 1716 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1717 |
</div>
|
| 1718 |
-
|
| 1719 |
-
|
| 1720 |
-
|
| 1721 |
-
)
|
| 1722 |
|
| 1723 |
-
# --- Risk message ---
|
| 1724 |
if high_speed_pct > 20:
|
| 1725 |
st.warning(
|
| 1726 |
f"High risk: {high_speed_pct:.1f}% of fatigue alerts occur at high speeds. "
|
|
|
|
| 1687 |
if col_speed and col_speed in df.columns:
|
| 1688 |
|
| 1689 |
# --- Threshold FIX > 20 km/h ---
|
| 1690 |
+
high_speed_threshold = 20
|
| 1691 |
|
| 1692 |
# --- Filter High-Speed Fatigue ---
|
| 1693 |
high_speed_fatigue = df[df[col_speed] > high_speed_threshold]
|
|
|
|
| 1695 |
# --- Persentase ---
|
| 1696 |
high_speed_pct = (len(high_speed_fatigue) / len(df) * 100) if len(df) > 0 else 0
|
| 1697 |
|
| 1698 |
+
# --- Title (optional) ---
|
| 1699 |
+
st.markdown(f"### High-Speed Fatigue Risk")
|
| 1700 |
|
| 1701 |
+
# --- Small centered card (not full width) ---
|
| 1702 |
+
col_left, col_center, col_right = st.columns([1, 2, 1])
|
| 1703 |
+
with col_center:
|
| 1704 |
+
st.markdown(
|
| 1705 |
+
f"""
|
| 1706 |
+
<div style="
|
| 1707 |
+
max-width:320px;
|
| 1708 |
+
margin:6px auto;
|
| 1709 |
+
padding:12px 16px;
|
| 1710 |
+
border-radius:10px;
|
| 1711 |
+
background:#d32f2f;
|
| 1712 |
+
color:#ffffff;
|
| 1713 |
+
text-align:center;
|
| 1714 |
+
box-shadow:0 6px 14px rgba(0,0,0,0.12);
|
| 1715 |
+
">
|
| 1716 |
+
<div style="font-size:26px; font-weight:700; line-height:1;">
|
| 1717 |
+
{len(high_speed_fatigue)}
|
| 1718 |
+
</div>
|
| 1719 |
+
<div style="font-size:14px; margin-top:4px; opacity:0.95;">
|
| 1720 |
+
{high_speed_pct:.1f}% of total alerts
|
| 1721 |
+
</div>
|
| 1722 |
+
<div style="font-size:12px; margin-top:6px; opacity:0.85;">
|
| 1723 |
+
Speed > {high_speed_threshold} km/h
|
| 1724 |
+
</div>
|
| 1725 |
</div>
|
| 1726 |
+
""",
|
| 1727 |
+
unsafe_allow_html=True
|
| 1728 |
+
)
|
|
|
|
| 1729 |
|
| 1730 |
+
# --- Risk message below the card ---
|
| 1731 |
if high_speed_pct > 20:
|
| 1732 |
st.warning(
|
| 1733 |
f"High risk: {high_speed_pct:.1f}% of fatigue alerts occur at high speeds. "
|