Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1714,21 +1714,45 @@ with col_insights:
|
|
| 1714 |
else:
|
| 1715 |
st.info("Shift data not available for Shift Pattern Analysis.")
|
| 1716 |
|
| 1717 |
-
|
| 1718 |
-
|
| 1719 |
-
|
| 1720 |
-
|
| 1721 |
-
|
| 1722 |
-
|
| 1723 |
-
|
| 1724 |
-
|
| 1725 |
-
|
| 1726 |
-
|
| 1727 |
-
|
| 1728 |
-
|
| 1729 |
-
|
| 1730 |
-
|
| 1731 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1732 |
|
| 1733 |
|
| 1734 |
# Kolom kanan: AI Recommendations
|
|
|
|
| 1714 |
else:
|
| 1715 |
st.info("Shift data not available for Shift Pattern Analysis.")
|
| 1716 |
|
| 1717 |
+
# 4. Operator Risk Profiling
|
| 1718 |
+
if col_operator and col_operator in df.columns:
|
| 1719 |
+
operator_alerts = df[col_operator].value_counts()
|
| 1720 |
+
top_risk_operators = operator_alerts.head(5) # Top 5 operators by alerts
|
| 1721 |
+
|
| 1722 |
+
st.markdown(f"**High-Risk Operator Identification**")
|
| 1723 |
+
|
| 1724 |
+
# Warna berdasarkan ranking 1–5
|
| 1725 |
+
colors = ["#d32f2f", "#e57373", "#ef9a9a", "#ffcdd2", "#ffe1e4"]
|
| 1726 |
+
|
| 1727 |
+
for idx, (op_name, count) in enumerate(top_risk_operators.items()):
|
| 1728 |
+
op_pct = (count / len(df)) * 100
|
| 1729 |
+
color = colors[idx] # warna sesuai ranking
|
| 1730 |
+
|
| 1731 |
+
# Kotak background warna (CSS)
|
| 1732 |
+
st.markdown(
|
| 1733 |
+
f"""
|
| 1734 |
+
<div style="
|
| 1735 |
+
background-color:{color};
|
| 1736 |
+
padding:12px;
|
| 1737 |
+
border-radius:10px;
|
| 1738 |
+
margin-bottom:8px;">
|
| 1739 |
+
<b>Operator: {op_name}</b><br>
|
| 1740 |
+
Alerts: {count}<br>
|
| 1741 |
+
Share: {op_pct:.1f}% of total alerts
|
| 1742 |
+
</div>
|
| 1743 |
+
""",
|
| 1744 |
+
unsafe_allow_html=True
|
| 1745 |
+
)
|
| 1746 |
+
|
| 1747 |
+
# Risk message
|
| 1748 |
+
if op_pct > 5:
|
| 1749 |
+
st.warning(f"Operator {op_name} has high fatigue risk ({op_pct:.1f}%). Consider coaching or rest plan.")
|
| 1750 |
+
else:
|
| 1751 |
+
st.info(f"Operator {op_name} fatigue risk is within acceptable range ({op_pct:.1f}%).")
|
| 1752 |
+
|
| 1753 |
+
else:
|
| 1754 |
+
st.info("Operator data not available for Operator Risk Profiling.")
|
| 1755 |
+
|
| 1756 |
|
| 1757 |
|
| 1758 |
# Kolom kanan: AI Recommendations
|