helliun commited on
Commit
fb978de
·
verified ·
1 Parent(s): 1169489

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -85,7 +85,7 @@ def analyze_results(df, overall_scores, subcategory_scores):
85
  user_answers = df['User Answer'].tolist()
86
  explanations = df['Explanation'].tolist()
87
  confidence = df['Confidence'].tolist()
88
- subcategories = df['Subcategory'].tolist()
89
 
90
  # Generate a summary of the results
91
  response = client.chat.completions.create(
@@ -99,7 +99,7 @@ def analyze_results(df, overall_scores, subcategory_scores):
99
  - Overall Overconfidence: {overall_scores['Overconfidence']}
100
  - Overall Underconfidence: {overall_scores['Underconfidence']}
101
 
102
- Subcategory scores:
103
  {subcategory_scores}
104
 
105
  The following is a list of my answers and confidence levels for each question, with the correct answers and subcategory:
@@ -161,18 +161,18 @@ def submit_answer(category, num_categories, num_questions, questions, index, use
161
  "User Answer": confidence > 0.5,
162
  "Correct Answer": question_data["answer"],
163
  "Confidence": 2*abs(confidence-0.5),
164
- "Subcategory": subcategory
165
  })
166
  index += 1
167
 
168
  if index >= len(questions):
169
  df = pd.DataFrame(user_answers)
170
  overall_scores = calculate_scores(df)
171
- subcategory_scores = df.groupby('Subcategory').apply(calculate_scores).to_dict()
172
  analysis = analyze_results(df, overall_scores, subcategory_scores)
173
 
174
- overall_score_df = pd.DataFrame([["Overall", *overall_scores.values()]], columns=['Subcategory', 'Accuracy', 'Overconfidence', 'Underconfidence'])
175
- subcategory_scores_df = pd.DataFrame([(subcategory, *score.values()) for subcategory, score in subcategory_scores.items()], columns=['Subcategory', 'Accuracy', 'Overconfidence', 'Underconfidence'])
176
  results_df = pd.concat([overall_score_df, subcategory_scores_df], ignore_index=True)
177
  results_df = gr.DataFrame(label="Results", value=results_df, visible=True)
178
  return "", index, gr.update(visible=False), user_answers, results_df, gr.update(visible=False), gr.update(visible=False), gr.update(value=analysis, visible=True), gr.update(visible=False)
@@ -183,11 +183,11 @@ def submit_answer(category, num_categories, num_questions, questions, index, use
183
  # Gradio UI setup
184
  with gr.Blocks(theme="soft") as app:
185
  gr.Markdown("""## Deep Quizzer
186
- See how well you know what you know. Enter a category and a quiz will be generated. Answer the True/False questions about it, and scores will then be calculated on your knowledge of the category, and on your ***knowledge of your knowledge*** of the category.""")
187
  with gr.Row():
188
- category_input = gr.Textbox(label="Category", placeholder="general knowledge", scale=4)
189
- num_categories_input = gr.Number(label="Number of Subcategories", value=5, scale=1, maximum=6)
190
- num_questions_input = gr.Number(label="Questions per Subcategory", value=5, scale=1, maximum=6)
191
  total_questions_display = gr.Number(label="Total Questions in Quiz", value=25, scale=1)
192
  submit_category = gr.Button("Generate Quiz")
193
  question_area = gr.Markdown(visible=False)
 
85
  user_answers = df['User Answer'].tolist()
86
  explanations = df['Explanation'].tolist()
87
  confidence = df['Confidence'].tolist()
88
+ subcategories = df['Section'].tolist()
89
 
90
  # Generate a summary of the results
91
  response = client.chat.completions.create(
 
99
  - Overall Overconfidence: {overall_scores['Overconfidence']}
100
  - Overall Underconfidence: {overall_scores['Underconfidence']}
101
 
102
+ Section scores:
103
  {subcategory_scores}
104
 
105
  The following is a list of my answers and confidence levels for each question, with the correct answers and subcategory:
 
161
  "User Answer": confidence > 0.5,
162
  "Correct Answer": question_data["answer"],
163
  "Confidence": 2*abs(confidence-0.5),
164
+ "Section": subcategory
165
  })
166
  index += 1
167
 
168
  if index >= len(questions):
169
  df = pd.DataFrame(user_answers)
170
  overall_scores = calculate_scores(df)
171
+ subcategory_scores = df.groupby('Section').apply(calculate_scores).to_dict()
172
  analysis = analyze_results(df, overall_scores, subcategory_scores)
173
 
174
+ overall_score_df = pd.DataFrame([["Overall", *overall_scores.values()]], columns=['Section', 'Accuracy', 'Overconfidence', 'Underconfidence'])
175
+ subcategory_scores_df = pd.DataFrame([(subcategory, *score.values()) for subcategory, score in subcategory_scores.items()], columns=['Section', 'Accuracy', 'Overconfidence', 'Underconfidence'])
176
  results_df = pd.concat([overall_score_df, subcategory_scores_df], ignore_index=True)
177
  results_df = gr.DataFrame(label="Results", value=results_df, visible=True)
178
  return "", index, gr.update(visible=False), user_answers, results_df, gr.update(visible=False), gr.update(visible=False), gr.update(value=analysis, visible=True), gr.update(visible=False)
 
183
  # Gradio UI setup
184
  with gr.Blocks(theme="soft") as app:
185
  gr.Markdown("""## Deep Quizzer
186
+ What do you know? What are you overconfident about? Underconfident? Deep Quizzer tests your knowledge, but also your ***meta-knowledge*** (your awareness of your knowledge). Taking a deep quiz will help you find gaps in your knowledge and learn how to be more confident in the topics you excel in!""")
187
  with gr.Row():
188
+ category_input = gr.Textbox(label="Topic", placeholder="general knowledge", scale=4)
189
+ num_categories_input = gr.Number(label="Number of Sections", value=5, scale=1, maximum=6)
190
+ num_questions_input = gr.Number(label="Questions per Section", value=5, scale=1, maximum=6)
191
  total_questions_display = gr.Number(label="Total Questions in Quiz", value=25, scale=1)
192
  submit_category = gr.Button("Generate Quiz")
193
  question_area = gr.Markdown(visible=False)