Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1526,75 +1526,51 @@ else:
|
|
| 1526 |
xaxis=dict(tickangle=45)
|
| 1527 |
)
|
| 1528 |
return fig
|
| 1529 |
-
|
| 1530 |
-
|
| 1531 |
-
|
| 1532 |
-
|
| 1533 |
-
|
| 1534 |
-
|
| 1535 |
-
|
| 1536 |
-
|
| 1537 |
-
|
| 1538 |
-
|
| 1539 |
-
#
|
| 1540 |
-
|
| 1541 |
-
|
| 1542 |
-
|
| 1543 |
-
|
| 1544 |
-
|
| 1545 |
-
|
| 1546 |
-
|
| 1547 |
-
|
| 1548 |
-
|
| 1549 |
-
|
| 1550 |
-
|
| 1551 |
-
|
| 1552 |
-
|
| 1553 |
-
|
| 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 |
-
|
| 1581 |
-
|
| 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 |
-
|
| 1592 |
-
|
| 1593 |
-
|
| 1594 |
-
|
| 1595 |
-
|
| 1596 |
-
|
| 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 |
# ===============================================================
|