Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
·
8be8621
1
Parent(s):
ccbe31d
add organizations filter
Browse files
app.py
CHANGED
@@ -98,6 +98,7 @@ merged_dfs = {k: format_data(v) for k, v in merged_dfs.items()}
|
|
98 |
# get constants
|
99 |
min_elo_score, max_elo_score, upper_models_per_month = get_constants(merged_dfs)
|
100 |
date_updated = elo_results["full"]["last_updated_datetime"].split(" ")[0]
|
|
|
101 |
|
102 |
###################
|
103 |
### Build and Plot Data
|
@@ -109,11 +110,13 @@ def get_data_split(dfs, set_name):
|
|
109 |
return df.reset_index(drop=True)
|
110 |
|
111 |
|
112 |
-
def filter_df(min_score, max_models_per_month, set_selector):
|
113 |
df = get_data_split(merged_dfs, set_name=set_selector)
|
114 |
|
115 |
# filter data
|
116 |
-
filtered_df = df[
|
|
|
|
|
117 |
|
118 |
filtered_df = (
|
119 |
filtered_df.groupby(["Month-Year", "License"], group_keys=False)
|
@@ -216,36 +219,45 @@ with gr.Blocks(
|
|
216 |
</div>
|
217 |
"""
|
218 |
)
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
249 |
|
250 |
# Show plot
|
251 |
plot = gr.Plot()
|
@@ -253,31 +265,37 @@ with gr.Blocks(
|
|
253 |
|
254 |
demo.load(
|
255 |
fn=filter_df,
|
256 |
-
inputs=[min_score, max_models_per_month, set_selector],
|
257 |
outputs=filtered_df,
|
258 |
).then(fn=build_plot, inputs=[toggle_annotations, filtered_df], outputs=plot)
|
259 |
|
260 |
min_score.change(
|
261 |
fn=filter_df,
|
262 |
-
inputs=[min_score, max_models_per_month, set_selector],
|
263 |
outputs=filtered_df,
|
264 |
).then(fn=build_plot, inputs=[toggle_annotations, filtered_df], outputs=plot)
|
265 |
|
266 |
max_models_per_month.change(
|
267 |
fn=filter_df,
|
268 |
-
inputs=[min_score, max_models_per_month, set_selector],
|
269 |
outputs=filtered_df,
|
270 |
).then(fn=build_plot, inputs=[toggle_annotations, filtered_df], outputs=plot)
|
271 |
|
272 |
toggle_annotations.change(
|
273 |
fn=filter_df,
|
274 |
-
inputs=[min_score, max_models_per_month, set_selector],
|
275 |
outputs=filtered_df,
|
276 |
).then(fn=build_plot, inputs=[toggle_annotations, filtered_df], outputs=plot)
|
277 |
|
278 |
set_selector.change(
|
279 |
fn=filter_df,
|
280 |
-
inputs=[min_score, max_models_per_month, set_selector],
|
|
|
|
|
|
|
|
|
|
|
|
|
281 |
outputs=filtered_df,
|
282 |
).then(fn=build_plot, inputs=[toggle_annotations, filtered_df], outputs=plot)
|
283 |
|
|
|
98 |
# get constants
|
99 |
min_elo_score, max_elo_score, upper_models_per_month = get_constants(merged_dfs)
|
100 |
date_updated = elo_results["full"]["last_updated_datetime"].split(" ")[0]
|
101 |
+
orgs = merged_dfs["Overall"].Organization.unique().tolist()
|
102 |
|
103 |
###################
|
104 |
### Build and Plot Data
|
|
|
110 |
return df.reset_index(drop=True)
|
111 |
|
112 |
|
113 |
+
def filter_df(min_score, max_models_per_month, set_selector, org_selector):
|
114 |
df = get_data_split(merged_dfs, set_name=set_selector)
|
115 |
|
116 |
# filter data
|
117 |
+
filtered_df = df[
|
118 |
+
(df["rating"] >= min_score) & (df["Organization"].isin(org_selector))
|
119 |
+
]
|
120 |
|
121 |
filtered_df = (
|
122 |
filtered_df.groupby(["Month-Year", "License"], group_keys=False)
|
|
|
219 |
</div>
|
220 |
"""
|
221 |
)
|
222 |
+
with gr.Group():
|
223 |
+
with gr.Row(variant="compact"):
|
224 |
+
set_selector = gr.Dropdown(
|
225 |
+
choices=list(CAT_NAME_TO_EXPLANATION.keys()),
|
226 |
+
label="Select Category",
|
227 |
+
value="Overall",
|
228 |
+
info="Select the category to visualize",
|
229 |
+
)
|
230 |
+
min_score = gr.Slider(
|
231 |
+
minimum=min_elo_score,
|
232 |
+
maximum=max_elo_score,
|
233 |
+
value=(max_elo_score - min_elo_score) * 0.3 + min_elo_score,
|
234 |
+
step=50,
|
235 |
+
label="Minimum ELO Score",
|
236 |
+
info="Filter out low scoring models",
|
237 |
+
)
|
238 |
+
max_models_per_month = gr.Slider(
|
239 |
+
value=upper_models_per_month - 2,
|
240 |
+
minimum=1,
|
241 |
+
maximum=upper_models_per_month,
|
242 |
+
step=1,
|
243 |
+
label="Max Models per Month (per License)",
|
244 |
+
info="Limit to N best models per month per license to reduce clutter",
|
245 |
+
)
|
246 |
+
toggle_annotations = gr.Radio(
|
247 |
+
choices=[True, False],
|
248 |
+
label="Overlay Best Model Name",
|
249 |
+
value=True,
|
250 |
+
info="Toggle to overlay the name of the best model per month per license",
|
251 |
+
)
|
252 |
+
with gr.Row(variant="compact"):
|
253 |
+
with gr.Accordion("More options", open=False):
|
254 |
+
org_selector = gr.Dropdown(
|
255 |
+
choices=orgs,
|
256 |
+
label="Filter by Organization",
|
257 |
+
value=orgs,
|
258 |
+
multiselect=True,
|
259 |
+
info="Limit organizations included in plot",
|
260 |
+
)
|
261 |
|
262 |
# Show plot
|
263 |
plot = gr.Plot()
|
|
|
265 |
|
266 |
demo.load(
|
267 |
fn=filter_df,
|
268 |
+
inputs=[min_score, max_models_per_month, set_selector, org_selector],
|
269 |
outputs=filtered_df,
|
270 |
).then(fn=build_plot, inputs=[toggle_annotations, filtered_df], outputs=plot)
|
271 |
|
272 |
min_score.change(
|
273 |
fn=filter_df,
|
274 |
+
inputs=[min_score, max_models_per_month, set_selector, org_selector],
|
275 |
outputs=filtered_df,
|
276 |
).then(fn=build_plot, inputs=[toggle_annotations, filtered_df], outputs=plot)
|
277 |
|
278 |
max_models_per_month.change(
|
279 |
fn=filter_df,
|
280 |
+
inputs=[min_score, max_models_per_month, set_selector, org_selector],
|
281 |
outputs=filtered_df,
|
282 |
).then(fn=build_plot, inputs=[toggle_annotations, filtered_df], outputs=plot)
|
283 |
|
284 |
toggle_annotations.change(
|
285 |
fn=filter_df,
|
286 |
+
inputs=[min_score, max_models_per_month, set_selector, org_selector],
|
287 |
outputs=filtered_df,
|
288 |
).then(fn=build_plot, inputs=[toggle_annotations, filtered_df], outputs=plot)
|
289 |
|
290 |
set_selector.change(
|
291 |
fn=filter_df,
|
292 |
+
inputs=[min_score, max_models_per_month, set_selector, org_selector],
|
293 |
+
outputs=filtered_df,
|
294 |
+
).then(fn=build_plot, inputs=[toggle_annotations, filtered_df], outputs=plot)
|
295 |
+
|
296 |
+
org_selector.change(
|
297 |
+
fn=filter_df,
|
298 |
+
inputs=[min_score, max_models_per_month, set_selector, org_selector],
|
299 |
outputs=filtered_df,
|
300 |
).then(fn=build_plot, inputs=[toggle_annotations, filtered_df], outputs=plot)
|
301 |
|