SHELLAPANDIANGANHUNGING commited on
Commit
1ab9794
·
verified ·
1 Parent(s): b580996

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -24
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
- # --- Judul ---
1699
- st.markdown(f"### **High-Speed Fatigue Risk (Speed > {high_speed_threshold} km/h)**")
1700
 
1701
- # --- Custom box merah ---
1702
- st.markdown(
1703
- f"""
1704
- <div style="
1705
- background-color:#d32f2f;
1706
- padding:18px;
1707
- border-radius:12px;
1708
- color:white;
1709
- font-size:22px;
1710
- font-weight:600;
1711
- text-align:center;
1712
- margin-bottom:10px;
1713
- ">
1714
- High-Speed Fatigue Events: {len(high_speed_fatigue)}
1715
- <div style="font-size:16px; font-weight:400; margin-top:4px;">
1716
- {high_speed_pct:.1f}% of total alerts
 
 
 
 
 
 
 
 
1717
  </div>
1718
- </div>
1719
- """,
1720
- unsafe_allow_html=True
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 &gt; {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. "