Signe22 commited on
Commit
b00263d
·
verified ·
1 Parent(s): fefe623

Update monitoring_app.py

Browse files
Files changed (1) hide show
  1. monitoring_app.py +33 -15
monitoring_app.py CHANGED
@@ -206,6 +206,10 @@ def render_review_queue(df: pd.DataFrame) -> None:
206
  def render_correct_cases(df: pd.DataFrame) -> None:
207
  st.subheader("Correct Classification Examples")
208
 
 
 
 
 
209
  correct_df = df[df["label_judgment"] == "correct"].copy()
210
 
211
  if correct_df.empty:
@@ -215,38 +219,52 @@ def render_correct_cases(df: pd.DataFrame) -> None:
215
  max_rows = st.slider(
216
  "Number of correct examples to display",
217
  5,
218
- 50,
219
- 10,
220
  key="correct_slider",
221
  )
222
 
223
- correct_df = correct_df.sort_values(
224
- "evaluated_at",
225
- ascending=False,
226
- ).head(max_rows)
227
 
228
  for _, row in correct_df.iterrows():
229
-
230
  published_str = (
231
  row["published_at"].strftime("%Y-%m-%d %H:%M UTC")
232
  if pd.notnull(row["published_at"])
233
  else "Unknown"
234
  )
235
 
236
- with st.expander(f"{row['title']}"):
 
 
 
 
237
 
238
- c1, c2, c3 = st.columns(3)
 
239
 
240
- c1.markdown(f"**Predicted label:** {row['predicted_label']}")
241
- c2.markdown(f"**Confidence:** {row['label_confidence']}")
242
- c3.markdown(f"**Published:** {published_str}")
 
243
 
244
- if pd.notnull(row["description"]):
245
- st.write(row["description"])
 
 
 
 
246
 
247
- st.markdown("**Judge explanation**")
 
 
 
 
248
  st.write(row["label_explanation"])
249
 
 
 
 
 
250
  if pd.notnull(row["url"]) and str(row["url"]).strip():
251
  st.markdown(f"[Open article]({row['url']})")
252
 
 
206
  def render_correct_cases(df: pd.DataFrame) -> None:
207
  st.subheader("Correct Classification Examples")
208
 
209
+ if df.empty:
210
+ st.info("No monitoring results available.")
211
+ return
212
+
213
  correct_df = df[df["label_judgment"] == "correct"].copy()
214
 
215
  if correct_df.empty:
 
219
  max_rows = st.slider(
220
  "Number of correct examples to display",
221
  5,
222
+ 100,
223
+ 20,
224
  key="correct_slider",
225
  )
226
 
227
+ correct_df = correct_df.sort_values("evaluated_at", ascending=False).head(max_rows)
 
 
 
228
 
229
  for _, row in correct_df.iterrows():
 
230
  published_str = (
231
  row["published_at"].strftime("%Y-%m-%d %H:%M UTC")
232
  if pd.notnull(row["published_at"])
233
  else "Unknown"
234
  )
235
 
236
+ evaluated_str = (
237
+ row["evaluated_at"].strftime("%Y-%m-%d %H:%M UTC")
238
+ if pd.notnull(row["evaluated_at"])
239
+ else "Unknown"
240
+ )
241
 
242
+ with st.expander(f"{row['title']}"):
243
+ m1, m2, m3, m4 = st.columns(4)
244
 
245
+ m1.markdown(f"**Predicted label:** {row['predicted_label']}")
246
+ m2.markdown(f"**Overall status:** {row['overall_status']}")
247
+ m3.markdown(f"**Source:** {row['source']}")
248
+ m4.markdown(f"**Published:** {published_str}")
249
 
250
+ st.markdown("**Description**")
251
+ st.write(
252
+ row["description"]
253
+ if pd.notnull(row["description"])
254
+ else "No description"
255
+ )
256
 
257
+ st.markdown("**Judge output**")
258
+ st.markdown(
259
+ f"**Label quality:** {row['label_judgment']} "
260
+ f"({row['label_confidence']})"
261
+ )
262
  st.write(row["label_explanation"])
263
 
264
+ st.markdown("**Metadata**")
265
+ st.caption(f"Article ID: {row['article_id']}")
266
+ st.caption(f"Evaluated at: {evaluated_str}")
267
+
268
  if pd.notnull(row["url"]) and str(row["url"]).strip():
269
  st.markdown(f"[Open article]({row['url']})")
270