Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1714,37 +1714,32 @@ with col_insights:
|
|
| 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(
|
| 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]
|
|
|
|
|
|
|
|
|
|
| 1730 |
|
| 1731 |
-
#
|
| 1732 |
st.markdown(
|
| 1733 |
-
f""
|
| 1734 |
-
<
|
| 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:
|
|
|
|
| 1714 |
else:
|
| 1715 |
st.info("Shift data not available for Shift Pattern Analysis.")
|
| 1716 |
|
| 1717 |
+
# 4. Operator Risk Profiling
|
| 1718 |
# 4. Operator Risk Profiling
|
| 1719 |
if col_operator and col_operator in df.columns:
|
| 1720 |
operator_alerts = df[col_operator].value_counts()
|
| 1721 |
top_risk_operators = operator_alerts.head(5) # Top 5 operators by alerts
|
| 1722 |
|
| 1723 |
+
st.markdown("**High-Risk Operator Identification**")
|
| 1724 |
|
| 1725 |
# Warna berdasarkan ranking 1–5
|
| 1726 |
colors = ["#d32f2f", "#e57373", "#ef9a9a", "#ffcdd2", "#ffe1e4"]
|
| 1727 |
|
| 1728 |
for idx, (op_name, count) in enumerate(top_risk_operators.items()):
|
| 1729 |
op_pct = (count / len(df)) * 100
|
| 1730 |
+
color = colors[idx] if idx < len(colors) else colors[-1]
|
| 1731 |
+
|
| 1732 |
+
# Teks normal untuk nama dan jumlah alert
|
| 1733 |
+
st.markdown(f"**Operator:** {op_name} \n**Alerts:** {count}")
|
| 1734 |
|
| 1735 |
+
# Hanya 'Share' yang berwarna sesuai ranking
|
| 1736 |
st.markdown(
|
| 1737 |
+
f"<span style='font-weight:600'>Share:</span> "
|
| 1738 |
+
f"<span style='color:{color}; font-weight:700'>{op_pct:.1f}% of total alerts</span>",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1739 |
unsafe_allow_html=True
|
| 1740 |
)
|
| 1741 |
|
| 1742 |
+
# Risk message (tetap gunakan component Streamlit agar konsisten)
|
| 1743 |
if op_pct > 5:
|
| 1744 |
st.warning(f"Operator {op_name} has high fatigue risk ({op_pct:.1f}%). Consider coaching or rest plan.")
|
| 1745 |
else:
|