"""SCI Figure Hub — Hyperparameter Sensitivity Heatmap (CC0-1.0)""" PALETTE = ["#FFFFD9", "#41B6C4", "#0C2C84"] import numpy as np import matplotlib.pyplot as plt from matplotlib.colors import LinearSegmentedColormap cmap = LinearSegmentedColormap.from_list("sci_palette", PALETTE) from matplotlib.patches import Rectangle plt.rcParams.update({"font.sans-serif": ["Arial", "DejaVu Sans"], "font.size": 8, "pdf.fonttype": 42}) xs = ["0.01", "0.05", "0.1", "0.2", "0.5"] ys = ["1e-4", "3e-4", "1e-3", "3e-3"] grid = np.array([[81.2, 84.5, 86.1, 85.0, 82.4], [83.8, 88.2, 91.4, 89.6, 85.1], [85.1, 89.7, 93.2, 91.0, 86.7], [82.0, 86.4, 89.5, 87.8, 83.2]]) fig, ax = plt.subplots(figsize=(3.6, 2.55), dpi=300) im = ax.pcolormesh(np.arange(grid.shape[1] + 1) - 0.5, np.arange(grid.shape[0] + 1) - 0.5, grid, cmap=cmap, vmin=80, vmax=94) ax.set_aspect("equal") ax.invert_yaxis() ax.set_xticks(range(len(xs)), xs) ax.set_yticks(range(len(ys)), ys) best_i, best_j = np.unravel_index(np.argmax(grid), grid.shape) ax.add_patch(Rectangle((best_j - 0.5, best_i - 0.5), 1, 1, fill=False, ec=PALETTE[0], lw=1.8)) for i in range(grid.shape[0]): for j in range(grid.shape[1]): ax.text(j, i, f"{grid[i, j]:.1f}", ha="center", va="center", fontsize=7.2, fontweight="bold" if (i, j) == (best_i, best_j) else "normal", color="#FFFFFF" if grid[i, j] > 88 else "#121C26") ax.set_xlabel("Temperature τ") ax.set_ylabel("Learning Rate") fig.colorbar(im, ax=ax, fraction=0.046, pad=0.04, label="F1 (%)") fig.tight_layout() fig.savefig("ablation_grid.pdf", bbox_inches="tight")