SHELLAPANDIANGANHUNGING commited on
Commit
7f35261
·
verified ·
1 Parent(s): 148a8da

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -15
app.py CHANGED
@@ -570,7 +570,7 @@ if 'temuan_kode_distrik' in df_local.columns:
570
  st.markdown("### Insight")
571
  insight_text = (
572
  f"<div class='ai-insight'>"
573
- f"In UM Area, all companies show almost the same average finding per person ration"
574
  # f"(<strong>{top_company_um['avg_monthly_ratio']:.2f}</strong>), warranting a focused safety audit. "
575
  # f"<strong>{low_company_um['nama_perusahaan']}</strong> shows the lowest ratio "
576
  # f"(<strong>{low_company_um['avg_monthly_ratio']:.2f}</strong>), which could reflect strong safety practices or requires verification of reporting completeness."
@@ -668,11 +668,11 @@ if not avg_ratio_per_location.empty:
668
 
669
  st.markdown("### Insight")
670
  insight_text = (
671
- f"<div class='ai-insight'>"
672
- f"The treemap visualizes the average finding-to-person ratio per location using a <strong>color gradient</strong>, indicating reporting activity levels. "
673
- f"Locations with <span style='color:#4CAF50; font-weight:bold;'>green</span> color have a high ratio, indicating high reporting activity or exposure. "
674
- f"Those with <span style='color:#FFB300; font-weight:bold;'>yellow</span> color have a medium ratio, indicating moderate reporting. "
675
- f"Locations with <span style='color:#D32F2F; font-weight:bold;'>red</span> color have a low ratio, indicating lower activity levels or potentially under-reporting. "
676
  f"<strong>{top_location['nama_lokasi_full']}</strong> shows the highest activity level "
677
  f"(<strong>{top_location['avg_monthly_ratio']:.2f}</strong>). "
678
  f"<strong>{low_location['nama_lokasi_full']}</strong> shows the lowest activity level "
@@ -1216,7 +1216,7 @@ try:
1216
  hover_name="Division",
1217
  size=[12] * len(risk_matrix),
1218
  size_max=15,
1219
- title="Audit Findings Risk Matrix: Avg Monthly Count vs Lead Time"
1220
  )
1221
  # Background quadrant (same as original)
1222
  fig.add_shape(type="rect", x0=X_LIMIT, x1=max_x, y0=Y_LIMIT, y1=max_y,
@@ -1250,7 +1250,7 @@ try:
1250
  # ============================
1251
  # 9. Summary Table
1252
  # ============================
1253
- st.markdown("<h3 style='font-size:12px; margin-bottom:6px;'>Summary (Avg Monthly Count vs Avg Lead Time)</h3>",unsafe_allow_html=True)
1254
 
1255
  st.dataframe(
1256
  risk_matrix.sort_values("Finding Count", ascending=False),
@@ -1464,7 +1464,7 @@ def predict_creators(df):
1464
  reason = f"Slope = {slope:.3f}, Coverage = {coverage*100:.1f}%. Avg: {avg_rate:.2f}/mo."
1465
  results.append({
1466
  'Creator': creator,
1467
- 'Avg Reports/Month': round(avg_rate, 2),
1468
  'Coverage (%)': round(coverage * 100, 1),
1469
  'Trend Slope': round(slope, 3),
1470
  'Trend': ascii_sparkline_pln(ts.values.tolist()),
@@ -1512,7 +1512,7 @@ def predict_locations(df):
1512
  reason = f"Slope = {slope:.3f}, Coverage = {coverage*100:.1f}%. Avg: {avg_rate:.2f}/mo."
1513
  results.append({
1514
  'Location': lokasi,
1515
- 'Avg Reports/Month': round(avg_rate, 2),
1516
  'Coverage (%)': round(coverage * 100, 1),
1517
  'Trend Slope': round(slope, 3),
1518
  'Trend': ascii_sparkline_pln(ts.values.tolist()),
@@ -1560,7 +1560,7 @@ def predict_divisions(df):
1560
  reason = f"Slope = {slope:.3f}, Coverage = {coverage*100:.1f}%. Avg: {avg_rate:.2f}/mo."
1561
  results.append({
1562
  'Division': div,
1563
- 'Avg Reports/Month': round(avg_rate, 2),
1564
  'Coverage (%)': round(coverage * 100, 1),
1565
  'Trend Slope': round(slope, 3),
1566
  'Trend': ascii_sparkline_pln(ts.values.tolist()),
@@ -1640,7 +1640,7 @@ df_category = predict_categories(df_filtered)
1640
  st.markdown("<div class='predictive-panel'>", unsafe_allow_html=True)
1641
  st.markdown("<div class='predictive-header'>1. Which Reporters Are Predicted to Have Less Future Inspections? (Top 10 Most Declining)</div>", unsafe_allow_html=True)
1642
  if not df_creator.empty:
1643
- cols = ['Creator', 'Avg Reports/Month', 'Coverage (%)', 'Trend Slope', 'Trend']
1644
 
1645
  # 🔥 Rename hanya untuk DISPLAY, bukan data asli
1646
  df_display = df_creator[cols].rename(columns={
@@ -1676,7 +1676,7 @@ st.markdown("</div>", unsafe_allow_html=True)
1676
  st.markdown("<div class='predictive-panel'>", unsafe_allow_html=True)
1677
  st.markdown("<div class='predictive-header'>2. Which Locations Are Predicted to Have Less Future Inspections? (Top 10 Most Declining)</div>", unsafe_allow_html=True)
1678
  if not df_location.empty:
1679
- cols = ['Location', 'Avg Reports/Month', 'Coverage (%)', 'Trend Slope', 'Trend']
1680
 
1681
  # # 🔥 Rename hanya untuk DISPLAY, bukan data asli
1682
  df_display = df_location[cols].rename(columns={
@@ -1712,7 +1712,7 @@ st.markdown("</div>", unsafe_allow_html=True)
1712
  st.markdown("<div class='predictive-panel'>", unsafe_allow_html=True)
1713
  st.markdown("<div class='predictive-header'>3. Which Divisions Are Predicted to Have Less Future Inspections? (Top 10 Most Declining)</div>", unsafe_allow_html=True)
1714
  if not df_division.empty:
1715
- cols = ['Division', 'Avg Reports/Month', 'Coverage (%)', 'Trend Slope', 'Trend']
1716
 
1717
  # # 🔥 Rename hanya untuk DISPLAY, bukan data asli
1718
  df_display = df_division[cols].rename(columns={
@@ -1823,7 +1823,7 @@ if not df_category.empty:
1823
 
1824
  # Layout
1825
  fig.update_layout(
1826
- title=dict(text="<b>Issue Category Trend vs Frequency (Non-Positive)</b>", x=0.5, y=0.95),
1827
  xaxis=dict(
1828
  title="Category",
1829
  tickangle=45,
 
570
  st.markdown("### Insight")
571
  insight_text = (
572
  f"<div class='ai-insight'>"
573
+ f"In UM Area, all companies show almost the same average finding per person ratio"
574
  # f"(<strong>{top_company_um['avg_monthly_ratio']:.2f}</strong>), warranting a focused safety audit. "
575
  # f"<strong>{low_company_um['nama_perusahaan']}</strong> shows the lowest ratio "
576
  # f"(<strong>{low_company_um['avg_monthly_ratio']:.2f}</strong>), which could reflect strong safety practices or requires verification of reporting completeness."
 
668
 
669
  st.markdown("### Insight")
670
  insight_text = (
671
+ # f"<div class='ai-insight'>"
672
+ # f"The treemap visualizes the average finding-to-person ratio per location using a <strong>color gradient</strong>, indicating reporting activity levels. "
673
+ # f"Locations with <span style='color:#4CAF50; font-weight:bold;'>green</span> color have a high ratio, indicating high reporting activity or exposure. "
674
+ # f"Those with <span style='color:#FFB300; font-weight:bold;'>yellow</span> color have a medium ratio, indicating moderate reporting. "
675
+ # f"Locations with <span style='color:#D32F2F; font-weight:bold;'>red</span> color have a low ratio, indicating lower activity levels or potentially under-reporting. "
676
  f"<strong>{top_location['nama_lokasi_full']}</strong> shows the highest activity level "
677
  f"(<strong>{top_location['avg_monthly_ratio']:.2f}</strong>). "
678
  f"<strong>{low_location['nama_lokasi_full']}</strong> shows the lowest activity level "
 
1216
  hover_name="Division",
1217
  size=[12] * len(risk_matrix),
1218
  size_max=15,
1219
+ # title="Audit Findings Risk Matrix: Avg Monthly Count vs Lead Time"
1220
  )
1221
  # Background quadrant (same as original)
1222
  fig.add_shape(type="rect", x0=X_LIMIT, x1=max_x, y0=Y_LIMIT, y1=max_y,
 
1250
  # ============================
1251
  # 9. Summary Table
1252
  # ============================
1253
+ # st.markdown("<h3 style='font-size:12px; margin-bottom:6px;'>Summary (Avg Monthly Count vs Avg Lead Time)</h3>",unsafe_allow_html=True)
1254
 
1255
  st.dataframe(
1256
  risk_matrix.sort_values("Finding Count", ascending=False),
 
1464
  reason = f"Slope = {slope:.3f}, Coverage = {coverage*100:.1f}%. Avg: {avg_rate:.2f}/mo."
1465
  results.append({
1466
  'Creator': creator,
1467
+ 'Reports/Month': round(avg_rate, 2),
1468
  'Coverage (%)': round(coverage * 100, 1),
1469
  'Trend Slope': round(slope, 3),
1470
  'Trend': ascii_sparkline_pln(ts.values.tolist()),
 
1512
  reason = f"Slope = {slope:.3f}, Coverage = {coverage*100:.1f}%. Avg: {avg_rate:.2f}/mo."
1513
  results.append({
1514
  'Location': lokasi,
1515
+ 'Reports/Month': round(avg_rate, 2),
1516
  'Coverage (%)': round(coverage * 100, 1),
1517
  'Trend Slope': round(slope, 3),
1518
  'Trend': ascii_sparkline_pln(ts.values.tolist()),
 
1560
  reason = f"Slope = {slope:.3f}, Coverage = {coverage*100:.1f}%. Avg: {avg_rate:.2f}/mo."
1561
  results.append({
1562
  'Division': div,
1563
+ 'Reports/Month': round(avg_rate, 2),
1564
  'Coverage (%)': round(coverage * 100, 1),
1565
  'Trend Slope': round(slope, 3),
1566
  'Trend': ascii_sparkline_pln(ts.values.tolist()),
 
1640
  st.markdown("<div class='predictive-panel'>", unsafe_allow_html=True)
1641
  st.markdown("<div class='predictive-header'>1. Which Reporters Are Predicted to Have Less Future Inspections? (Top 10 Most Declining)</div>", unsafe_allow_html=True)
1642
  if not df_creator.empty:
1643
+ cols = ['Creator', 'Reports/Month', 'Coverage (%)', 'Trend Slope', 'Trend']
1644
 
1645
  # 🔥 Rename hanya untuk DISPLAY, bukan data asli
1646
  df_display = df_creator[cols].rename(columns={
 
1676
  st.markdown("<div class='predictive-panel'>", unsafe_allow_html=True)
1677
  st.markdown("<div class='predictive-header'>2. Which Locations Are Predicted to Have Less Future Inspections? (Top 10 Most Declining)</div>", unsafe_allow_html=True)
1678
  if not df_location.empty:
1679
+ cols = ['Location', 'Reports/Month', 'Coverage (%)', 'Trend Slope', 'Trend']
1680
 
1681
  # # 🔥 Rename hanya untuk DISPLAY, bukan data asli
1682
  df_display = df_location[cols].rename(columns={
 
1712
  st.markdown("<div class='predictive-panel'>", unsafe_allow_html=True)
1713
  st.markdown("<div class='predictive-header'>3. Which Divisions Are Predicted to Have Less Future Inspections? (Top 10 Most Declining)</div>", unsafe_allow_html=True)
1714
  if not df_division.empty:
1715
+ cols = ['Division', 'Reports/Month', 'Coverage (%)', 'Trend Slope', 'Trend']
1716
 
1717
  # # 🔥 Rename hanya untuk DISPLAY, bukan data asli
1718
  df_display = df_division[cols].rename(columns={
 
1823
 
1824
  # Layout
1825
  fig.update_layout(
1826
+ # title=dict(text="<b>Issue Category Trend vs Frequency (Non-Positive)</b>", x=0.5, y=0.95),
1827
  xaxis=dict(
1828
  title="Category",
1829
  tickangle=45,