tpierrot commited on
Commit
5c93746
β€’
1 Parent(s): a5c85f4

add graph tab

Browse files
Files changed (1) hide show
  1. app.py +67 -1
app.py CHANGED
@@ -92,6 +92,36 @@ def get_dataset(
92
  return leaderboard_table
93
 
94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  with gr.Blocks() as demo:
96
  with gr.Row():
97
  gr.Image(banner_url, height=160, scale=1)
@@ -137,7 +167,12 @@ with gr.Blocks() as demo:
137
  elem_id="leaderboard-table",
138
  )
139
 
140
- with gr.TabItem("πŸ“ˆ Metrics", elem_id="od-benchmark-tab-table", id=1):
 
 
 
 
 
141
  gr.Markdown("Hey hey hey", elem_classes="markdown-text")
142
 
143
  gr.Markdown(f"Last updated on **{_LAST_UPDATED}**", elem_classes="markdown-text")
@@ -182,4 +217,35 @@ with gr.Blocks() as demo:
182
  outputs=dataframe,
183
  )
184
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  demo.launch()
 
92
  return leaderboard_table
93
 
94
 
95
+ def get_bar_plot(
96
+ histone_tasks: List[str],
97
+ regulatory_tasks: List[str],
98
+ rna_tasks: List[str],
99
+ target_metric: str = "MCC",
100
+ aggregation_method: str = "mean",
101
+ ):
102
+ tasks = histone_tasks + regulatory_tasks + rna_tasks
103
+
104
+ aggr_fn = getattr(np, aggregation_method)
105
+ scores = _ORIGINAL_DF[target_metric].apply(retrieve_array_from_text).apply(aggr_fn)
106
+ scores = scores.apply(format_number)
107
+ df = _ORIGINAL_DF.drop(columns=_METRICS)
108
+ df["Score"] = scores / len(tasks)
109
+ df = df.query(f"Dataset == {tasks}")
110
+
111
+ bar_plot = gr.BarPlot.update(
112
+ df,
113
+ x="Model",
114
+ y="Score",
115
+ color="Dataset",
116
+ width=500,
117
+ x_label_angle=-45,
118
+ x_title="Model",
119
+ y_title="Score",
120
+ color_legend_title="Downstream Task",
121
+ )
122
+ return bar_plot
123
+
124
+
125
  with gr.Blocks() as demo:
126
  with gr.Row():
127
  gr.Image(banner_url, height=160, scale=1)
 
167
  elem_id="leaderboard-table",
168
  )
169
 
170
+ with gr.TabItem("πŸ“ˆ Graph", elem_id="od-benchmark-tab-table", id=2):
171
+ bar_plot = gr.BarPlot(
172
+ elem_id="leaderboard-bar-plot",
173
+ )
174
+
175
+ with gr.TabItem("ℹ️ Metrics", elem_id="od-benchmark-tab-table", id=1):
176
  gr.Markdown("Hey hey hey", elem_classes="markdown-text")
177
 
178
  gr.Markdown(f"Last updated on **{_LAST_UPDATED}**", elem_classes="markdown-text")
 
217
  outputs=dataframe,
218
  )
219
 
220
+ histone_tasks.change(
221
+ get_bar_plot,
222
+ inputs=[histone_tasks, regulatory_tasks, rna_tasks, metric_choice, aggr_choice],
223
+ outputs=bar_plot,
224
+ )
225
+ regulatory_tasks.change(
226
+ get_bar_plot,
227
+ inputs=[histone_tasks, regulatory_tasks, rna_tasks, metric_choice, aggr_choice],
228
+ outputs=bar_plot,
229
+ )
230
+ rna_tasks.change(
231
+ get_bar_plot,
232
+ inputs=[histone_tasks, regulatory_tasks, rna_tasks, metric_choice, aggr_choice],
233
+ outputs=bar_plot,
234
+ )
235
+ metric_choice.change(
236
+ get_bar_plot,
237
+ inputs=[histone_tasks, regulatory_tasks, rna_tasks, metric_choice, aggr_choice],
238
+ outputs=bar_plot,
239
+ )
240
+ aggr_choice.change(
241
+ get_bar_plot,
242
+ inputs=[histone_tasks, regulatory_tasks, rna_tasks, metric_choice, aggr_choice],
243
+ outputs=bar_plot,
244
+ )
245
+ demo.load(
246
+ fn=get_bar_plot,
247
+ inputs=[histone_tasks, regulatory_tasks, rna_tasks, metric_choice, aggr_choice],
248
+ outputs=bar_plot,
249
+ )
250
+
251
  demo.launch()