import json import matplotlib.pyplot as plt # 文件路径 basic_path="/home/tianqiu/tts_schedule/batch_infer/results/mathhard/Qwen_Qwen2.5-7B-Instruct/Majority/output/acc4_new.jsonl" parallel_path="/home/tianqiu/tts_schedule/batch_infer/results/mathhard/Qwen_Qwen2.5-7B-Instruct/Majority/output/acc8.jsonl" sequence_vote_path="/home/tianqiu/tts_schedule/batch_infer/results/mathhard/Qwen_Qwen2.5-7B-Instruct/Sequence_vote/output_data/acc4_new.jsonl" # 加载数据 with open(basic_path, 'r') as f: basic_data = json.load(f) with open(parallel_path, 'r') as f: parallel_data = json.load(f) with open(sequence_vote_path, 'r') as f: sequence_vote_data = json.load(f) # 获取正确索引 correct_indices_basic = basic_data['correct_indices'] correct_indices_parallel = parallel_data['correct_indices'] correct_indices_sequence_vote = sequence_vote_data['correct_indices'] # 计算parallel和sequence vote的交集 intersection = set(correct_indices_parallel) & set(correct_indices_sequence_vote) # 计算basic在intersection中的部分 basic_in_intersection = set(correct_indices_basic) & intersection intersection_not_basic = intersection - set(correct_indices_basic) # 打印统计信息 print(f"Intersection: {len(intersection)}") print(f"Parallel not in Sequence vote: {len(correct_indices_parallel) - len(intersection)}") print(f"Sequence vote not in Parallel: {len(correct_indices_sequence_vote) - len(intersection)}") print(f"Basic in intersection: {len(basic_in_intersection)}") print(f"Intersection not in basic: {len(intersection_not_basic)}") # 绘制饼图 - 将intersection分成两部分:basic在intersection中的部分,和intersection中不在basic中的部分 plt.figure(figsize=(10, 8)) plt.pie([len(basic_in_intersection), len(intersection_not_basic), len(correct_indices_parallel) - len(intersection), len(correct_indices_sequence_vote) - len(intersection)], labels=['Basic in Intersection', 'Intersection not in Basic', 'Parallel not in Sequence vote', 'Sequence vote not in Parallel'], autopct='%1.1f%%', colors=['#ff9999', '#66b3ff', '#99ff99', '#ffcc99']) plt.title('Comparison of Correct Answers Across Different Methods') plt.axis('equal') plt.show()