Spaces:
Running
Running
Aiden Anderson
commited on
Commit
·
f8fd7c1
1
Parent(s):
7ba0657
made visualization function of correct/incorrect answers
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import random
|
|
3 |
import gradio as gr
|
4 |
from News import News
|
5 |
from Gemma import GemmaLLM
|
|
|
6 |
|
7 |
# %%
|
8 |
class Cooldown:
|
@@ -270,4 +271,27 @@ with gr.Blocks() as demo:
|
|
270 |
|
271 |
demo.launch()
|
272 |
|
273 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
import gradio as gr
|
4 |
from News import News
|
5 |
from Gemma import GemmaLLM
|
6 |
+
import matplotlib.pyplot as plt
|
7 |
|
8 |
# %%
|
9 |
class Cooldown:
|
|
|
271 |
|
272 |
demo.launch()
|
273 |
|
274 |
+
import matplotlib.pyplot as plt
|
275 |
+
|
276 |
+
def visualize_quiz_answers(answers, *quiz_items):
|
277 |
+
"""
|
278 |
+
Visualization of correct/incorrect answers from the quiz
|
279 |
+
"""
|
280 |
+
if not answers:
|
281 |
+
return None
|
282 |
+
|
283 |
+
correct = 0
|
284 |
+
|
285 |
+
for user_ans, question in zip(answers, quiz_items):
|
286 |
+
if user_ans == question["correct_answer"]:
|
287 |
+
correct += 1
|
288 |
+
|
289 |
+
incorrect = len(answers) - correct
|
290 |
+
|
291 |
+
fig, ax = plt.subplots()
|
292 |
+
ax.bar(["Correct", "Incorrect"], [correct, incorrect])
|
293 |
+
ax.set_ylabel("Questions")
|
294 |
+
ax.set_title("Quiz Score Summary")
|
295 |
+
|
296 |
+
return fig
|
297 |
+
|