Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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['
|
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 |
-
|
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 |
-
"
|
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('
|
172 |
analysis = analyze_results(df, overall_scores, subcategory_scores)
|
173 |
|
174 |
-
overall_score_df = pd.DataFrame([["Overall", *overall_scores.values()]], columns=['
|
175 |
-
subcategory_scores_df = pd.DataFrame([(subcategory, *score.values()) for subcategory, score in subcategory_scores.items()], columns=['
|
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 |
-
|
187 |
with gr.Row():
|
188 |
-
category_input = gr.Textbox(label="
|
189 |
-
num_categories_input = gr.Number(label="Number of
|
190 |
-
num_questions_input = gr.Number(label="Questions per
|
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)
|