hysts HF staff commited on
Commit
a44a96e
1 Parent(s): 1d28680

Add graph for average scores

Browse files
Files changed (1) hide show
  1. app.py +42 -0
app.py CHANGED
@@ -328,6 +328,39 @@ def plot_size_vs_score(df: pd.DataFrame, hidden_df: pd.DataFrame) -> go.Figure:
328
  return fig
329
 
330
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
331
  SELECT_ALL_BUTTON_LABEL = "Select All"
332
  SELECT_ALL_BUTTON_LABEL_JA = "全選択"
333
  SELECT_NONE_BUTTON_LABEL = "Select None"
@@ -458,6 +491,7 @@ with gr.Blocks() as demo_leaderboard:
458
  )
459
 
460
  graph_size_vs_score = gr.Plot(label="Model size vs. Average score")
 
461
 
462
  # Dummy leaderboard for handling the case when the user uses backspace key
463
  hidden_leaderboard_table_for_search = gr.Dataframe(
@@ -526,6 +560,14 @@ with gr.Blocks() as demo_leaderboard:
526
  queue=False,
527
  )
528
 
 
 
 
 
 
 
 
 
529
  # Check query parameter once at startup and update search bar + hidden component
530
  demo_leaderboard.load(fn=load_query, outputs=[search_bar, hidden_search_bar])
531
 
 
328
  return fig
329
 
330
 
331
+ def plot_average_scores(df: pd.DataFrame, hidden_df: pd.DataFrame) -> go.Figure:
332
+ df2 = hidden_df.iloc[df.index]
333
+ df2 = df2[["model_name_for_query"] + [column for column in df.columns if column.startswith("AVG ")]]
334
+ df2 = df2.rename(columns={"model_name_for_query": "Model"})
335
+ df2 = df2.rename(
336
+ columns={
337
+ column: column.replace("AVG (", "").replace(")", "") for column in df2.columns if column.startswith("AVG ")
338
+ }
339
+ )
340
+ df2 = df2.set_index("Model").astype(float)
341
+
342
+ fig = go.Figure()
343
+ for i, (name, row) in enumerate(df2.iterrows()):
344
+ visible = True if i < 3 else "legendonly" # Display only the first 3 models
345
+ fig.add_trace(
346
+ go.Scatterpolar(
347
+ r=row.values,
348
+ theta=row.index,
349
+ fill="toself",
350
+ name=name,
351
+ hovertemplate="%{theta}: %{r}",
352
+ visible=visible,
353
+ )
354
+ )
355
+ fig.update_layout(
356
+ polar={
357
+ "radialaxis": {"range": [0, 1]},
358
+ },
359
+ showlegend=True,
360
+ )
361
+ return fig
362
+
363
+
364
  SELECT_ALL_BUTTON_LABEL = "Select All"
365
  SELECT_ALL_BUTTON_LABEL_JA = "全選択"
366
  SELECT_NONE_BUTTON_LABEL = "Select None"
 
491
  )
492
 
493
  graph_size_vs_score = gr.Plot(label="Model size vs. Average score")
494
+ graph_average_scores = gr.Plot(label="Model Performance across Task Categories")
495
 
496
  # Dummy leaderboard for handling the case when the user uses backspace key
497
  hidden_leaderboard_table_for_search = gr.Dataframe(
 
560
  queue=False,
561
  )
562
 
563
+ leaderboard_table.change(
564
+ fn=plot_average_scores,
565
+ inputs=[leaderboard_table, hidden_leaderboard_table_for_search],
566
+ outputs=graph_average_scores,
567
+ api_name=False,
568
+ queue=False,
569
+ )
570
+
571
  # Check query parameter once at startup and update search bar + hidden component
572
  demo_leaderboard.load(fn=load_query, outputs=[search_bar, hidden_search_bar])
573