summaryrefslogtreecommitdiff
path: root/data/my_results
diff options
context:
space:
mode:
authormaszhongming <mingz5@illinois.edu>2025-09-16 15:15:29 -0500
committermaszhongming <mingz5@illinois.edu>2025-09-16 15:15:29 -0500
commit73c194f304f827b55081b15524479f82a1b7d94c (patch)
tree5e8660e421915420892c5eca18f1ad680f80a861 /data/my_results
Initial commit
Diffstat (limited to 'data/my_results')
-rw-r--r--data/my_results/evaluate_gemini.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/data/my_results/evaluate_gemini.py b/data/my_results/evaluate_gemini.py
new file mode 100644
index 0000000..aa37b89
--- /dev/null
+++ b/data/my_results/evaluate_gemini.py
@@ -0,0 +1,24 @@
+import pandas as pd
+import json
+
+# Define file paths for the CSV files
+file_path1 = 'data/my_results/gemini_2.0_flash_kg_rag_based_mcq_0.csv'
+
+
+# Load the CSV files into DataFrames
+df1 = pd.read_csv(file_path1)
+
+# Define a function to check if the correct answer is present in the LLM answer
+def contains_correct_answer(row):
+ try:
+ return row['correct_answer'] == json.loads(row['llm_answer'].replace('```', '').replace('\n', '').replace('json', '').replace('{{', '{').replace('}}', '}').split('}')[0] + '}')['answer']
+ except:
+ return False
+
+# Apply the function to each row of the DataFrames
+df1['is_correct'] = df1.apply(contains_correct_answer, axis=1)
+
+# Calculate the percentage of correct answers
+correct_rate1 = df1['is_correct'].mean() * 100
+print(f"Correct Answer Rate for {file_path1}: {correct_rate1:.2f}%")
+