Fola-lad commited on
Commit
049d8fd
1 Parent(s): aa56214

Vote on core windows only, skip first/last (recording start/stop transients)

Browse files
Files changed (1) hide show
  1. src/phyphox_app_block.py +12 -4
src/phyphox_app_block.py CHANGED
@@ -206,8 +206,13 @@ def render_phyphox_tab(
206
  pred_labels = [LABEL_MAP[int(np.argmax(p))] for p in probs_all]
207
 
208
  from collections import Counter
209
- vote = Counter(pred_labels).most_common(1)[0][0]
210
- avg_conf = float(np.mean(np.max(probs_all, axis=1))) * 100
 
 
 
 
 
211
 
212
  st.success(f"**{vote}** 路 {avg_conf:.1f}% avg confidence")
213
  st.markdown(f"_{EXPLANATIONS[vote]}_")
@@ -217,15 +222,18 @@ def render_phyphox_tab(
217
  rows = []
218
  for i, (p, label) in enumerate(zip(probs_all, pred_labels)):
219
  t_start = i * STEP / FS
 
220
  rows.append({
221
  "Window": i + 1,
222
  "Time (s)": f"{t_start:.1f}鈥搟t_start + WINDOW/FS:.1f}",
223
- "Prediction": label,
224
  "Confidence": f"{float(np.max(p))*100:.1f}%",
225
  })
226
  st.dataframe(pd.DataFrame(rows), use_container_width=True)
 
 
227
 
228
- mean_probs = probs_all.mean(axis=0)
229
  st.markdown("**Average confidence across all classes**")
230
  st.bar_chart(pd.DataFrame(
231
  {"Confidence (%)": [float(mean_probs[i]) * 100 for i in range(6)]},
 
206
  pred_labels = [LABEL_MAP[int(np.argmax(p))] for p in probs_all]
207
 
208
  from collections import Counter
209
+ # Skip first and last window for the final vote: these are typically
210
+ # contaminated by recording start/stop transients (person not yet
211
+ # in full motion, or the gravity filter still warming up).
212
+ core = probs_all[1:-1] if n_windows > 3 else probs_all
213
+ core_labels = [LABEL_MAP[int(np.argmax(p))] for p in core]
214
+ vote = Counter(core_labels).most_common(1)[0][0]
215
+ avg_conf = float(np.mean(np.max(core, axis=1))) * 100
216
 
217
  st.success(f"**{vote}** 路 {avg_conf:.1f}% avg confidence")
218
  st.markdown(f"_{EXPLANATIONS[vote]}_")
 
222
  rows = []
223
  for i, (p, label) in enumerate(zip(probs_all, pred_labels)):
224
  t_start = i * STEP / FS
225
+ is_edge = (i == 0 or i == n_windows - 1) and n_windows > 3
226
  rows.append({
227
  "Window": i + 1,
228
  "Time (s)": f"{t_start:.1f}鈥搟t_start + WINDOW/FS:.1f}",
229
+ "Prediction": label + (" *" if is_edge else ""),
230
  "Confidence": f"{float(np.max(p))*100:.1f}%",
231
  })
232
  st.dataframe(pd.DataFrame(rows), use_container_width=True)
233
+ if n_windows > 3:
234
+ st.caption("* Edge windows excluded from overall vote (recording start/stop transient).")
235
 
236
+ mean_probs = core.mean(axis=0)
237
  st.markdown("**Average confidence across all classes**")
238
  st.bar_chart(pd.DataFrame(
239
  {"Confidence (%)": [float(mean_probs[i]) * 100 for i in range(6)]},