Spaces:
Running
Running
Heatmap: Rotate the graph from horizontal to vertical for easier reading and add the transpose parameter for easier switching in the future
Browse files- analyze_winscore.py +17 -2
- server.py +10 -2
analyze_winscore.py
CHANGED
|
@@ -219,8 +219,22 @@ def create_heatmap(data_matrix, original_scores,
|
|
| 219 |
y_axis_label="Task",
|
| 220 |
x_axis_visible=True,
|
| 221 |
y_axis_visible=True,
|
|
|
|
| 222 |
):
|
| 223 |
FONTSIZE = 9
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
|
| 225 |
n_rows, n_cols = data_matrix.shape
|
| 226 |
cell_size = 22
|
|
@@ -245,12 +259,13 @@ def create_heatmap(data_matrix, original_scores,
|
|
| 245 |
width=plot_width,
|
| 246 |
height=plot_height,
|
| 247 |
x_range=list(data_matrix.index),
|
| 248 |
-
y_range=
|
| 249 |
-
toolbar_location=
|
| 250 |
tools="pan,wheel_zoom,box_zoom,reset,save",
|
| 251 |
active_drag=None,
|
| 252 |
x_axis_label=x_axis_label,
|
| 253 |
y_axis_label=y_axis_label,
|
|
|
|
| 254 |
)
|
| 255 |
|
| 256 |
# Create the color mapper for the heatmap
|
|
|
|
| 219 |
y_axis_label="Task",
|
| 220 |
x_axis_visible=True,
|
| 221 |
y_axis_visible=True,
|
| 222 |
+
transpose=False,
|
| 223 |
):
|
| 224 |
FONTSIZE = 9
|
| 225 |
+
|
| 226 |
+
if transpose:
|
| 227 |
+
data_matrix = data_matrix.T
|
| 228 |
+
original_scores = original_scores.T
|
| 229 |
+
x_axis_label, y_axis_label = y_axis_label, x_axis_label
|
| 230 |
+
x_axis_visible, y_axis_visible = y_axis_visible, x_axis_visible
|
| 231 |
+
toolbar_location = "right"
|
| 232 |
+
x_axis_location = "above"
|
| 233 |
+
y_range=list(reversed(data_matrix.columns))
|
| 234 |
+
else:
|
| 235 |
+
toolbar_location = "below"
|
| 236 |
+
x_axis_location = "below"
|
| 237 |
+
y_range=list(data_matrix.columns)
|
| 238 |
|
| 239 |
n_rows, n_cols = data_matrix.shape
|
| 240 |
cell_size = 22
|
|
|
|
| 259 |
width=plot_width,
|
| 260 |
height=plot_height,
|
| 261 |
x_range=list(data_matrix.index),
|
| 262 |
+
y_range=y_range,
|
| 263 |
+
toolbar_location=toolbar_location,
|
| 264 |
tools="pan,wheel_zoom,box_zoom,reset,save",
|
| 265 |
active_drag=None,
|
| 266 |
x_axis_label=x_axis_label,
|
| 267 |
y_axis_label=y_axis_label,
|
| 268 |
+
x_axis_location=x_axis_location,
|
| 269 |
)
|
| 270 |
|
| 271 |
# Create the color mapper for the heatmap
|
server.py
CHANGED
|
@@ -846,12 +846,15 @@ class LeaderboardServer:
|
|
| 846 |
# Apply quantile transformation independently for each row
|
| 847 |
normalized_scores_sub = original_scores_sub.apply(lambda x: (x - x.min()) / (x.max() - x.min()), axis=0)
|
| 848 |
|
|
|
|
|
|
|
| 849 |
# Call the heatmap function with the normalized data
|
| 850 |
p1 = create_heatmap(
|
| 851 |
normalized_scores_sub,
|
| 852 |
original_scores_sub * 100,
|
| 853 |
x_axis_label="Model ≥16B",
|
| 854 |
y_axis_label=fig_y_axis_label,
|
|
|
|
| 855 |
)
|
| 856 |
|
| 857 |
# Smaller models
|
|
@@ -867,10 +870,15 @@ class LeaderboardServer:
|
|
| 867 |
x_axis_label="Model <16B",
|
| 868 |
y_axis_label=fig_y_axis_label,
|
| 869 |
y_axis_visible=False,
|
|
|
|
| 870 |
)
|
| 871 |
|
| 872 |
-
|
| 873 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 874 |
|
| 875 |
return layout
|
| 876 |
|
|
|
|
| 846 |
# Apply quantile transformation independently for each row
|
| 847 |
normalized_scores_sub = original_scores_sub.apply(lambda x: (x - x.min()) / (x.max() - x.min()), axis=0)
|
| 848 |
|
| 849 |
+
transpose = True
|
| 850 |
+
|
| 851 |
# Call the heatmap function with the normalized data
|
| 852 |
p1 = create_heatmap(
|
| 853 |
normalized_scores_sub,
|
| 854 |
original_scores_sub * 100,
|
| 855 |
x_axis_label="Model ≥16B",
|
| 856 |
y_axis_label=fig_y_axis_label,
|
| 857 |
+
transpose=transpose,
|
| 858 |
)
|
| 859 |
|
| 860 |
# Smaller models
|
|
|
|
| 870 |
x_axis_label="Model <16B",
|
| 871 |
y_axis_label=fig_y_axis_label,
|
| 872 |
y_axis_visible=False,
|
| 873 |
+
transpose=transpose,
|
| 874 |
)
|
| 875 |
|
| 876 |
+
if transpose:
|
| 877 |
+
from bokeh.layouts import column
|
| 878 |
+
layout = column(p1, p2)
|
| 879 |
+
else:
|
| 880 |
+
from bokeh.layouts import row
|
| 881 |
+
layout = row(p1, p2)
|
| 882 |
|
| 883 |
return layout
|
| 884 |
|