saattrupdan
commited on
Commit
·
a4a8904
1
Parent(s):
76e4363
feat: Add `show_scale`, default False
Browse files
app.py
CHANGED
@@ -177,18 +177,26 @@ def main() -> None:
|
|
177 |
interactive=True,
|
178 |
scale=2,
|
179 |
)
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
with gr.Row():
|
187 |
plot = gr.Plot(
|
188 |
value=produce_radial_plot(
|
189 |
model_ids_dropdown.value,
|
190 |
language_names=language_names_dropdown.value,
|
191 |
use_win_ratio=use_win_ratio_checkbox.value,
|
|
|
192 |
results_dfs=results_dfs,
|
193 |
),
|
194 |
)
|
@@ -205,27 +213,20 @@ def main() -> None:
|
|
205 |
)
|
206 |
|
207 |
# Update plot when anything changes
|
208 |
-
|
209 |
-
fn=partial(produce_radial_plot, results_dfs=results_dfs),
|
210 |
-
inputs=[
|
211 |
-
model_ids_dropdown, language_names_dropdown, use_win_ratio_checkbox
|
212 |
-
],
|
213 |
-
outputs=plot,
|
214 |
-
)
|
215 |
-
model_ids_dropdown.change(
|
216 |
-
fn=partial(produce_radial_plot, results_dfs=results_dfs),
|
217 |
-
inputs=[
|
218 |
-
model_ids_dropdown, language_names_dropdown, use_win_ratio_checkbox
|
219 |
-
],
|
220 |
-
outputs=plot,
|
221 |
-
)
|
222 |
-
use_win_ratio_checkbox.change(
|
223 |
fn=partial(produce_radial_plot, results_dfs=results_dfs),
|
224 |
inputs=[
|
225 |
-
model_ids_dropdown,
|
|
|
|
|
|
|
226 |
],
|
227 |
outputs=plot,
|
228 |
)
|
|
|
|
|
|
|
|
|
229 |
|
230 |
demo.launch()
|
231 |
|
@@ -313,6 +314,7 @@ def produce_radial_plot(
|
|
313 |
model_ids: list[str],
|
314 |
language_names: list[str],
|
315 |
use_win_ratio: bool,
|
|
|
316 |
results_dfs: dict[Language, pd.DataFrame] | None,
|
317 |
) -> go.Figure:
|
318 |
"""Produce a radial plot as a plotly figure.
|
@@ -324,6 +326,8 @@ def produce_radial_plot(
|
|
324 |
The names of the languages to include in the plot.
|
325 |
use_win_ratio:
|
326 |
Whether to use win ratios (as opposed to raw scores).
|
|
|
|
|
327 |
results_dfs:
|
328 |
The results dataframes for each language.
|
329 |
|
@@ -417,7 +421,7 @@ def produce_radial_plot(
|
|
417 |
|
418 |
# Builds the radial plot from the results
|
419 |
fig.update_layout(
|
420 |
-
polar=dict(radialaxis=dict(visible=
|
421 |
showlegend=True,
|
422 |
title=title,
|
423 |
width=800,
|
|
|
177 |
interactive=True,
|
178 |
scale=2,
|
179 |
)
|
180 |
+
with gr.Column():
|
181 |
+
use_win_ratio_checkbox = gr.Checkbox(
|
182 |
+
label="Compare models with win ratios (as opposed to raw scores)",
|
183 |
+
value=True,
|
184 |
+
interactive=True,
|
185 |
+
scale=1,
|
186 |
+
)
|
187 |
+
show_scale_checkbox = gr.Checkbox(
|
188 |
+
label="Show scale on plot",
|
189 |
+
value=False,
|
190 |
+
interactive=True,
|
191 |
+
scale=1,
|
192 |
+
)
|
193 |
with gr.Row():
|
194 |
plot = gr.Plot(
|
195 |
value=produce_radial_plot(
|
196 |
model_ids_dropdown.value,
|
197 |
language_names=language_names_dropdown.value,
|
198 |
use_win_ratio=use_win_ratio_checkbox.value,
|
199 |
+
show_scale=show_scale_checkbox.value,
|
200 |
results_dfs=results_dfs,
|
201 |
),
|
202 |
)
|
|
|
213 |
)
|
214 |
|
215 |
# Update plot when anything changes
|
216 |
+
update_plot_kwargs = dict(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
217 |
fn=partial(produce_radial_plot, results_dfs=results_dfs),
|
218 |
inputs=[
|
219 |
+
model_ids_dropdown,
|
220 |
+
language_names_dropdown,
|
221 |
+
use_win_ratio_checkbox,
|
222 |
+
show_scale_checkbox,
|
223 |
],
|
224 |
outputs=plot,
|
225 |
)
|
226 |
+
language_names_dropdown.change(**update_plot_kwargs)
|
227 |
+
model_ids_dropdown.change(**update_plot_kwargs)
|
228 |
+
use_win_ratio_checkbox.change(**update_plot_kwargs)
|
229 |
+
show_scale_checkbox.change(**update_plot_kwargs)
|
230 |
|
231 |
demo.launch()
|
232 |
|
|
|
314 |
model_ids: list[str],
|
315 |
language_names: list[str],
|
316 |
use_win_ratio: bool,
|
317 |
+
show_scale: bool,
|
318 |
results_dfs: dict[Language, pd.DataFrame] | None,
|
319 |
) -> go.Figure:
|
320 |
"""Produce a radial plot as a plotly figure.
|
|
|
326 |
The names of the languages to include in the plot.
|
327 |
use_win_ratio:
|
328 |
Whether to use win ratios (as opposed to raw scores).
|
329 |
+
show_scale:
|
330 |
+
Whether to show the scale on the plot.
|
331 |
results_dfs:
|
332 |
The results dataframes for each language.
|
333 |
|
|
|
421 |
|
422 |
# Builds the radial plot from the results
|
423 |
fig.update_layout(
|
424 |
+
polar=dict(radialaxis=dict(visible=show_scale, range=[0, 100])),
|
425 |
showlegend=True,
|
426 |
title=title,
|
427 |
width=800,
|