File size: 1,125 Bytes
03b8479 22197f0 03b8479 22197f0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import matplotlib.pyplot as plt
def compute_sample_scores(results, prompt):
# 示例评分 - 实际应用中可以用更复杂的评估逻辑
return {
"sd_v1_5": {"G": 4, "R": 4, "A": 4, "E": 3},
"openjourney_v4": {"G": 3, "R": 4, "A": 5, "E": 3},
"ldm_256": {"G": 2, "R": 3, "A": 3, "E": 5}
}
def plot_radar(scores_dict, out_path="radar.png"):
categories = list(scores_dict.values())[0].keys()
N = len(categories)
fig, ax = plt.subplots(figsize=(6, 6), subplot_kw=dict(polar=True))
for model, scores in scores_dict.items():
values = list(scores.values())
values += values[:1] # 闭合雷达图
angles = [n / float(N) * 2 * 3.14159 for n in range(N)]
angles += angles[:1]
ax.plot(angles, values, linewidth=1, linestyle='solid', label=model)
ax.fill(angles, values, alpha=0.1)
ax.set_xticks(angles[:-1])
ax.set_xticklabels(categories)
ax.set_title("GRACE 评估雷达图 (CPU模式)", size=12, y=1.1)
ax.legend(loc='upper right')
plt.savefig(out_path, bbox_inches='tight')
plt.close() |