Spaces:
Runtime error
Runtime error
Tristan Thrush
commited on
Commit
·
6be0e9c
1
Parent(s):
38045c5
made -unspecified- the default selection for config and split, added metric selection to url, speedup for case where no dataset is selected
Browse files
app.py
CHANGED
|
@@ -141,6 +141,7 @@ print(default_only_verified)
|
|
| 141 |
default_dataset = first_query_params.get("dataset", [None])[0]
|
| 142 |
default_split = first_query_params.get("split", [None])[0]
|
| 143 |
default_config = first_query_params.get("config", [None])[0]
|
|
|
|
| 144 |
|
| 145 |
only_verified_results = st.sidebar.checkbox(
|
| 146 |
"Filter for Verified Results",
|
|
@@ -177,7 +178,9 @@ dataset = st.sidebar.selectbox(
|
|
| 177 |
|
| 178 |
dataframe = dataframe[dataframe.only_verified == only_verified_results]
|
| 179 |
|
| 180 |
-
|
|
|
|
|
|
|
| 181 |
|
| 182 |
if dataset != "-any-":
|
| 183 |
dataset_df = dataframe[dataframe.dataset == dataset]
|
|
@@ -187,8 +190,12 @@ else:
|
|
| 187 |
dataset_df = dataset_df.dropna(axis="columns", how="all")
|
| 188 |
|
| 189 |
if len(dataset_df) > 0:
|
| 190 |
-
|
| 191 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 192 |
|
| 193 |
if dataset != "-any-":
|
| 194 |
config = st.sidebar.selectbox(
|
|
@@ -199,7 +206,12 @@ if len(dataset_df) > 0:
|
|
| 199 |
)
|
| 200 |
dataset_df = dataset_df[dataset_df.config == config]
|
| 201 |
|
| 202 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
split = st.sidebar.selectbox(
|
| 204 |
"Split",
|
| 205 |
selectable_splits,
|
|
@@ -207,7 +219,9 @@ if len(dataset_df) > 0:
|
|
| 207 |
help="Filter the results on the current leaderboard by the dataset split. Self-reported results might not report the split, which is why \"-unspecified-\" is an option."
|
| 208 |
)
|
| 209 |
|
| 210 |
-
|
|
|
|
|
|
|
| 211 |
|
| 212 |
dataset_df = dataset_df[dataset_df.split == split]
|
| 213 |
|
|
@@ -220,9 +234,14 @@ if len(dataset_df) > 0:
|
|
| 220 |
sorting_metric = st.sidebar.radio(
|
| 221 |
"Sorting Metric",
|
| 222 |
selectable_metrics,
|
|
|
|
| 223 |
help="Select the metric to sort the leaderboard by. Click on the metric name in the leaderboard to reverse the sorting order."
|
| 224 |
)
|
| 225 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
st.markdown(
|
| 227 |
"Please click on the model's name to be redirected to its model card."
|
| 228 |
)
|
|
@@ -237,7 +256,7 @@ if len(dataset_df) > 0:
|
|
| 237 |
|
| 238 |
if dataset == "-any-":
|
| 239 |
st.info(
|
| 240 |
-
"Note: you haven't chosen a dataset, so the leaderboard is showing the best scoring model for
|
| 241 |
)
|
| 242 |
|
| 243 |
# Make the default metric appear right after model names and dataset names
|
|
@@ -251,8 +270,8 @@ if len(dataset_df) > 0:
|
|
| 251 |
dataset_df = dataset_df.sort_values(by=cols[sorting_metric_index:], ascending=[metric in ascending_metrics for metric in cols[sorting_metric_index:]])
|
| 252 |
dataset_df = dataset_df.replace(np.nan, '-')
|
| 253 |
|
| 254 |
-
# If dataset is "-any-", only show the best model for
|
| 255 |
-
# The leaderboard is way too long and doesn't give the users a feel for all of
|
| 256 |
# the datasets available for a task.
|
| 257 |
if dataset == "-any-":
|
| 258 |
filtered_dataset_df_dict = {column: [] for column in dataset_df.columns}
|
|
@@ -263,6 +282,7 @@ if len(dataset_df) > 0:
|
|
| 263 |
filtered_dataset_df_dict[column].append(row[column])
|
| 264 |
seen_datasets.add(row["dataset"])
|
| 265 |
dataset_df = pd.DataFrame(filtered_dataset_df_dict)
|
|
|
|
| 266 |
|
| 267 |
# Make the leaderboard
|
| 268 |
gb = GridOptionsBuilder.from_dataframe(dataset_df)
|
|
|
|
| 141 |
default_dataset = first_query_params.get("dataset", [None])[0]
|
| 142 |
default_split = first_query_params.get("split", [None])[0]
|
| 143 |
default_config = first_query_params.get("config", [None])[0]
|
| 144 |
+
default_metric = first_query_params.get("metric", [None])[0]
|
| 145 |
|
| 146 |
only_verified_results = st.sidebar.checkbox(
|
| 147 |
"Filter for Verified Results",
|
|
|
|
| 178 |
|
| 179 |
dataframe = dataframe[dataframe.only_verified == only_verified_results]
|
| 180 |
|
| 181 |
+
current_query_params = {"dataset": [dataset], "only_verified": [int(only_verified_results)], "task": [task]}
|
| 182 |
+
|
| 183 |
+
st.experimental_set_query_params(**current_query_params)
|
| 184 |
|
| 185 |
if dataset != "-any-":
|
| 186 |
dataset_df = dataframe[dataframe.dataset == dataset]
|
|
|
|
| 190 |
dataset_df = dataset_df.dropna(axis="columns", how="all")
|
| 191 |
|
| 192 |
if len(dataset_df) > 0:
|
| 193 |
+
config_set = set(dataset_df["config"])
|
| 194 |
+
if "-unspecified-" in config_set:
|
| 195 |
+
config_set.discard("-unspecified-")
|
| 196 |
+
selectable_configs = ["-unspecified-"] + list(config_set)
|
| 197 |
+
else:
|
| 198 |
+
selectable_configs = list(config_set)
|
| 199 |
|
| 200 |
if dataset != "-any-":
|
| 201 |
config = st.sidebar.selectbox(
|
|
|
|
| 206 |
)
|
| 207 |
dataset_df = dataset_df[dataset_df.config == config]
|
| 208 |
|
| 209 |
+
split_set = set(dataset_df["split"])
|
| 210 |
+
if "-unspecified-" in split_set:
|
| 211 |
+
split_set.discard("-unspecified-")
|
| 212 |
+
selectable_splits = ["-unspecified-"] + list(split_set)
|
| 213 |
+
else:
|
| 214 |
+
selectable_splits = list(split_set)
|
| 215 |
split = st.sidebar.selectbox(
|
| 216 |
"Split",
|
| 217 |
selectable_splits,
|
|
|
|
| 219 |
help="Filter the results on the current leaderboard by the dataset split. Self-reported results might not report the split, which is why \"-unspecified-\" is an option."
|
| 220 |
)
|
| 221 |
|
| 222 |
+
current_query_params.update({"config": [config], "split": [split]})
|
| 223 |
+
|
| 224 |
+
st.experimental_set_query_params(**current_query_params)
|
| 225 |
|
| 226 |
dataset_df = dataset_df[dataset_df.split == split]
|
| 227 |
|
|
|
|
| 234 |
sorting_metric = st.sidebar.radio(
|
| 235 |
"Sorting Metric",
|
| 236 |
selectable_metrics,
|
| 237 |
+
index=selectable_metrics.index(default_metric) if default_metric in selectable_metrics else 0,
|
| 238 |
help="Select the metric to sort the leaderboard by. Click on the metric name in the leaderboard to reverse the sorting order."
|
| 239 |
)
|
| 240 |
|
| 241 |
+
current_query_params.update({"metric": [sorting_metric]})
|
| 242 |
+
|
| 243 |
+
st.experimental_set_query_params(**current_query_params)
|
| 244 |
+
|
| 245 |
st.markdown(
|
| 246 |
"Please click on the model's name to be redirected to its model card."
|
| 247 |
)
|
|
|
|
| 256 |
|
| 257 |
if dataset == "-any-":
|
| 258 |
st.info(
|
| 259 |
+
"Note: you haven't chosen a dataset, so the leaderboard is showing the best scoring model for a random sample of the datasets available."
|
| 260 |
)
|
| 261 |
|
| 262 |
# Make the default metric appear right after model names and dataset names
|
|
|
|
| 270 |
dataset_df = dataset_df.sort_values(by=cols[sorting_metric_index:], ascending=[metric in ascending_metrics for metric in cols[sorting_metric_index:]])
|
| 271 |
dataset_df = dataset_df.replace(np.nan, '-')
|
| 272 |
|
| 273 |
+
# If dataset is "-any-", only show the best model for a random sample of 100 datasets.
|
| 274 |
+
# Otherwise The leaderboard is way too long and doesn't give the users a feel for all of
|
| 275 |
# the datasets available for a task.
|
| 276 |
if dataset == "-any-":
|
| 277 |
filtered_dataset_df_dict = {column: [] for column in dataset_df.columns}
|
|
|
|
| 282 |
filtered_dataset_df_dict[column].append(row[column])
|
| 283 |
seen_datasets.add(row["dataset"])
|
| 284 |
dataset_df = pd.DataFrame(filtered_dataset_df_dict)
|
| 285 |
+
dataset_df = dataset_df.sample(min(100, len(dataset_df)))
|
| 286 |
|
| 287 |
# Make the leaderboard
|
| 288 |
gb = GridOptionsBuilder.from_dataframe(dataset_df)
|