| 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 |
| |
| 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) |
| |
| 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) |