File size: 1,153 Bytes
fabf9c5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
31
32
33
34
35
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

def heatmap(file_path, output_path):
    df = pd.read_excel(file_path)

    counts = [0] * 8
    # 统计每个标签 prediction 正确的数量
    for i in range(8):
        for j in range(400 * i, 400 * (i+1)):
            if df.iloc[j]["answer"] == df.iloc[j]["prediction"]:
                counts[i] += 1
        counts[i] = counts[i] / 400
    counts.insert(4, 0)
    # 将数量重塑为 3x3 矩阵
    matrix = [counts[0:3], counts[3:6], counts[6:9]]

    plt.figure(figsize=(6, 6))
    ax = sns.heatmap(matrix, annot=False, fmt="d", cmap="OrRd", xticklabels=[0,1,2], yticklabels=[0,1,2], vmin=0.125, vmax=0.925)
    ax.set_aspect("equal")
    plt.title("Correct Predictions Heatmap")
    plt.xlabel("Column")
    plt.ylabel("Row")
    plt.savefig(output_path)    

#全图
full_file_path = "./llava_uhd_final_ShapeGrid_sudoku_ShapeGrid.xlsx"
output_path = "./heatmap_full.png"
heatmap(full_file_path, output_path)

#切片
slice_file_path = "./llava_uhd_resampler_query_49_ShapeGrid_sudoku.xlsx"
output_path = "./heatmap_slice.png"
heatmap(slice_file_path, output_path)