SHELLAPANDIANGANHUNGING commited on
Commit
6b58028
·
verified ·
1 Parent(s): ec9a8a9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -59
app.py CHANGED
@@ -1526,75 +1526,51 @@ else:
1526
  xaxis=dict(tickangle=45)
1527
  )
1528
  return fig
1529
-
1530
- # ===============================================================
1531
- # CHARTS
1532
- # ===============================================================
1533
- col1, col2 = st.columns(2)
1534
- with col1:
1535
- st.plotly_chart(plot_chart(top_ob, "OB HAULER Operators (Hazard Gradient)"), use_container_width=True)
1536
- with col2:
1537
- st.plotly_chart(plot_chart(top_coal, "HAULING COAL Operators (Hazard Gradient)"), use_container_width=True)
1538
-
1539
- # ===============================================================
1540
- # AI INSIGHTS — tetap dalam bahasa Inggris, tanpa emoticon
1541
- # ===============================================================
1542
- col_insight1, col_insight2 = st.columns(2)
1543
-
1544
- with col_insight1:
1545
- if not top_ob.empty:
1546
- st.markdown("### OB HAULER Analysis")
1547
- ob_worsening = len(top_ob[top_ob['slope'] > 0])
1548
- ob_improving = len(top_ob[top_ob['slope'] < 0])
1549
- ob_one_time = len(top_ob[top_ob['slope'] == 0])
1550
- ob_avg_risk = top_ob['weekly_avg'].mean()
1551
- ob_max_risk = top_ob['weekly_avg'].max()
1552
- ob_insights = []
1553
- if ob_worsening > ob_improving:
1554
- ob_insights.append(f"{ob_worsening} out of 10 top risk operators are showing <span class='trend-up'>worsening</span> trends.")
1555
- else:
1556
- ob_insights.append(f"{ob_improving} out of 10 top risk operators are showing <span class='trend-down'>improvement</span>.")
1557
- if ob_one_time > 0:
1558
- ob_insights.append(f"{ob_one_time} operators are classified as <b>One Time Event</b> (single-week activity).")
1559
- ob_insights.append(f"Average risk: {ob_avg_risk:.2f} events/week (max: {ob_max_risk:.2f}).")
1560
-
1561
- for insight in ob_insights:
1562
- st.markdown(f"""
1563
- <div class="ai-insight-box">
1564
- <div class="ai-insight-title">Risk Summary</div>
1565
- <p>{insight}</p>
1566
- </div>
1567
- """, unsafe_allow_html=True)
1568
- else:
1569
- st.info("No OB HAULER data for analysis.")
1570
-
1571
  with col_insight2:
1572
  if not top_coal.empty:
1573
- st.markdown("### HAULING COAL Analysis")
1574
  coal_worsening = len(top_coal[top_coal['slope'] > 0])
1575
  coal_improving = len(top_coal[top_coal['slope'] < 0])
1576
  coal_one_time = len(top_coal[top_coal['slope'] == 0])
1577
  coal_avg_risk = top_coal['weekly_avg'].mean()
1578
  coal_max_risk = top_coal['weekly_avg'].max()
1579
- coal_insights = []
1580
- if coal_worsening > coal_improving:
1581
- coal_insights.append(f"{coal_worsening} out of 10 top risk operators are showing <span class='trend-up'>worsening</span> trends.")
1582
- else:
1583
- coal_insights.append(f"{coal_improving} out of 10 top risk operators are showing <span class='trend-down'>improvement</span>.")
1584
- if coal_one_time > 0:
1585
- coal_insights.append(f"{coal_one_time} operators are classified as <b>One Time Event</b> (single-week activity).")
1586
- coal_insights.append(f"Average risk: {coal_avg_risk:.2f} events/week (max: {coal_max_risk:.2f}).")
1587
-
1588
  for insight in coal_insights:
1589
  st.markdown(f"""
1590
  <div class="ai-insight-box">
1591
- <div class="ai-insight-title">Risk Summary</div>
1592
- <p>{insight}</p>
1593
- </div>
1594
- """, unsafe_allow_html=True)
1595
- else:
1596
- st.info("No HAULING COAL data for analysis.")
1597
-
1598
  # ===============================================================
1599
  # RECOMMENDATIONS
1600
  # ===============================================================
 
1526
  xaxis=dict(tickangle=45)
1527
  )
1528
  return fig
1529
+ col_insight1, col_insight2 = st.columns(2)
1530
+ with col_insight1:
1531
+ if not top_ob.empty:
1532
+ st.markdown("### OB HAULER Hazard Analysis")
1533
+ ob_worsening = len(top_ob[top_ob['slope'] > 0])
1534
+ ob_improving = len(top_ob[top_ob['slope'] < 0])
1535
+ ob_one_time = len(top_ob[top_ob['slope'] == 0])
1536
+ ob_avg_risk = top_ob['weekly_avg'].mean()
1537
+ ob_max_risk = top_ob['weekly_avg'].max()
1538
+
1539
+ # Buat list 3 poin yang selalu ada, tanpa kondisional untuk jumlah poin
1540
+ ob_insights = [
1541
+ f"{ob_worsening} out of 10 top hazard operators are showing <span class='trend-up'>worsening</span> trends.",
1542
+ f"{ob_one_time} operators are classified as <b>One Time Event</b> (single-week activity).",
1543
+ f"Average hazard: {ob_avg_risk:.2f} events/week (max: {ob_max_risk:.2f})."
1544
+ ]
1545
+ for insight in ob_insights:
1546
+ st.markdown(f"""
1547
+ <div class="ai-insight-box">
1548
+ <div class="ai-insight-title">Hazard Summary</div>
1549
+ <p>{insight}</p>
1550
+ </div>
1551
+ """, unsafe_allow_html=True)
1552
+ else:
1553
+ st.info("No OB HAULER data for analysis.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1554
  with col_insight2:
1555
  if not top_coal.empty:
1556
+ st.markdown("### HAULING COAL Hazard Analysis")
1557
  coal_worsening = len(top_coal[top_coal['slope'] > 0])
1558
  coal_improving = len(top_coal[top_coal['slope'] < 0])
1559
  coal_one_time = len(top_coal[top_coal['slope'] == 0])
1560
  coal_avg_risk = top_coal['weekly_avg'].mean()
1561
  coal_max_risk = top_coal['weekly_avg'].max()
1562
+ coal_insights = [f"{coal_worsening} out of 10 top hazard operators are showing <span class='trend-up'>worsening</span> trends.",
1563
+ f"{coal_one_time} operators are classified as <b>One Time Event</b> (single-week activity).",
1564
+ f"Average hazard: {coal_avg_risk:.2f} events/week (max: {coal_max_risk:.2f})."]
 
 
 
 
 
 
1565
  for insight in coal_insights:
1566
  st.markdown(f"""
1567
  <div class="ai-insight-box">
1568
+ <div class="ai-insight-title">Hazard Summary</div>
1569
+ <p>{insight}</p>
1570
+ </div>
1571
+ """, unsafe_allow_html=True)
1572
+ else:
1573
+ st.info("No HAULING COAL data for analysis.")
 
1574
  # ===============================================================
1575
  # RECOMMENDATIONS
1576
  # ===============================================================