taesiri commited on
Commit
d901742
·
1 Parent(s): bf0e4cf

add more details in results page

Browse files
Files changed (1) hide show
  1. app.py +45 -8
app.py CHANGED
@@ -183,19 +183,18 @@ def render_results():
183
  )
184
  st.markdown("## User Performance Breakdown")
185
 
186
- categories = set(session_state.is_classifier_correct.values())
 
 
 
187
  breakdown_stats_correct = {c: 0 for c in categories}
188
  breakdown_stats_wrong = {c: 0 for c in categories}
189
 
190
  experiment_summary = []
191
 
192
  for q in session_state.user_feedback.keys():
193
- category = session_state.is_classifier_correct[q]
194
- user_feedback_boolean = (
195
- True if session_state.user_feedback[q] == "Correct" else False
196
- )
197
-
198
- is_user_correct = category == user_feedback_boolean
199
 
200
  if is_user_correct:
201
  breakdown_stats_correct[category] += 1
@@ -214,7 +213,7 @@ def render_results():
214
  is_user_correct,
215
  ]
216
  )
217
-
218
  experiment_summary_df = pd.DataFrame.from_records(
219
  experiment_summary,
220
  columns=[
@@ -232,6 +231,44 @@ def render_results():
232
  st.download_button(
233
  "Press to Download", csv, "summary.csv", "text/csv", key="download-records"
234
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
235
 
236
 
237
  def render_menu():
 
183
  )
184
  st.markdown("## User Performance Breakdown")
185
 
186
+ categories = [
187
+ "Correct",
188
+ "Wrong",
189
+ ] # set(session_state.is_classifier_correct.values())
190
  breakdown_stats_correct = {c: 0 for c in categories}
191
  breakdown_stats_wrong = {c: 0 for c in categories}
192
 
193
  experiment_summary = []
194
 
195
  for q in session_state.user_feedback.keys():
196
+ category = "Correct" if session_state.is_classifier_correct[q] else "Wrong"
197
+ is_user_correct = category == session_state.user_feedback[q]
 
 
 
 
198
 
199
  if is_user_correct:
200
  breakdown_stats_correct[category] += 1
 
213
  is_user_correct,
214
  ]
215
  )
216
+ ################################### Summary Table
217
  experiment_summary_df = pd.DataFrame.from_records(
218
  experiment_summary,
219
  columns=[
 
231
  st.download_button(
232
  "Press to Download", csv, "summary.csv", "text/csv", key="download-records"
233
  )
234
+ ################################### SHOW BREAKDOWN
235
+ user_pf_by_model_pred = experiment_summary_df.groupby("Category").agg(
236
+ {"Is User Prediction Correct": ["count", "sum", "mean"]}
237
+ )
238
+ # rename columns
239
+ user_pf_by_model_pred.columns = user_pf_by_model_pred.columns.droplevel(0)
240
+ user_pf_by_model_pred.columns = [
241
+ "Count",
242
+ "Correct User Guess",
243
+ "Mean User Performance",
244
+ ]
245
+ user_pf_by_model_pred.index.name = "Model Prediction"
246
+ st.write("User performance break down by Model prediction:", user_pf_by_model_pred)
247
+ csv = convert_df(user_pf_by_model_pred)
248
+ st.download_button(
249
+ "Press to Download",
250
+ csv,
251
+ "user-performance-by-model-prediction.csv",
252
+ "text/csv",
253
+ key="download-performance-by-model-prediction",
254
+ )
255
+ ################################### CONFUSION MATRIX
256
+
257
+ confusion_matrix = pd.crosstab(
258
+ experiment_summary_df["Category"],
259
+ experiment_summary_df["User Prediction"],
260
+ rownames=["Actual"],
261
+ colnames=["Predicted"],
262
+ )
263
+ st.write("Confusion Matrix", confusion_matrix)
264
+ csv = convert_df(confusion_matrix)
265
+ st.download_button(
266
+ "Press to Download",
267
+ csv,
268
+ "confusion-matrix.csv",
269
+ "text/csv",
270
+ key="download-confusiion-matrix",
271
+ )
272
 
273
 
274
  def render_menu():