Spaces:
Runtime error
Runtime error
Tristan Thrush
commited on
Commit
·
3bebb47
1
Parent(s):
80f2297
added secondary sorting if there are ties for the sorting metric, made sorting order for sorting metric reversible but not the other metrics
Browse files
app.py
CHANGED
@@ -119,15 +119,13 @@ dataset_df = dataframe[dataframe.dataset == dataset]
|
|
119 |
dataset_df = dataset_df.dropna(axis="columns", how="all")
|
120 |
|
121 |
selectable_metrics = list(filter(lambda column: column not in ("model_id", "dataset"), dataset_df.columns))
|
122 |
-
|
123 |
-
"
|
124 |
selectable_metrics,
|
125 |
)
|
126 |
|
127 |
dataset_df = dataset_df.filter(["model_id"] + selectable_metrics)
|
128 |
dataset_df = dataset_df.dropna(thresh=2) # Want at least two non-na values (one for model_id and one for a metric).
|
129 |
-
dataset_df = dataset_df.sort_values(by=default_metric, ascending=default_metric in ascending_metrics)
|
130 |
-
dataset_df = dataset_df.replace(np.nan, '-')
|
131 |
|
132 |
st.markdown(
|
133 |
"Please click on the model's name to be redirected to its model card."
|
@@ -139,12 +137,17 @@ st.markdown(
|
|
139 |
|
140 |
# Make the default metric appear right after model names
|
141 |
cols = dataset_df.columns.tolist()
|
142 |
-
cols.remove(
|
143 |
-
cols = cols[:1] + [
|
144 |
dataset_df = dataset_df[cols]
|
145 |
|
|
|
|
|
|
|
|
|
146 |
# Make the leaderboard
|
147 |
gb = GridOptionsBuilder.from_dataframe(dataset_df)
|
|
|
148 |
gb.configure_column(
|
149 |
"model_id",
|
150 |
cellRenderer=JsCode('''function(params) {return '<a target="_blank" href="https://huggingface.co/'+params.value+'">'+params.value+'</a>'}'''),
|
@@ -153,7 +156,8 @@ for name in selectable_metrics:
|
|
153 |
gb.configure_column(name, type=["numericColumn","numberColumnFilter","customNumericFormat"], precision=2, aggFunc='sum')
|
154 |
|
155 |
gb.configure_column(
|
156 |
-
|
|
|
157 |
cellStyle=JsCode('''function(params) { return {'backgroundColor': '#FFD21E'}}''')
|
158 |
)
|
159 |
|
|
|
119 |
dataset_df = dataset_df.dropna(axis="columns", how="all")
|
120 |
|
121 |
selectable_metrics = list(filter(lambda column: column not in ("model_id", "dataset"), dataset_df.columns))
|
122 |
+
sorting_metric = st.sidebar.radio(
|
123 |
+
"Sorting Metric",
|
124 |
selectable_metrics,
|
125 |
)
|
126 |
|
127 |
dataset_df = dataset_df.filter(["model_id"] + selectable_metrics)
|
128 |
dataset_df = dataset_df.dropna(thresh=2) # Want at least two non-na values (one for model_id and one for a metric).
|
|
|
|
|
129 |
|
130 |
st.markdown(
|
131 |
"Please click on the model's name to be redirected to its model card."
|
|
|
137 |
|
138 |
# Make the default metric appear right after model names
|
139 |
cols = dataset_df.columns.tolist()
|
140 |
+
cols.remove(sorting_metric)
|
141 |
+
cols = cols[:1] + [sorting_metric] + cols[1:]
|
142 |
dataset_df = dataset_df[cols]
|
143 |
|
144 |
+
# Sort the leaderboard, giving the sorting metric highest priority and then ordering by other metrics in the case of equal values.
|
145 |
+
dataset_df = dataset_df.sort_values(by=cols[1:], ascending=[metric in ascending_metrics for metric in cols[1:]])
|
146 |
+
dataset_df = dataset_df.replace(np.nan, '-')
|
147 |
+
|
148 |
# Make the leaderboard
|
149 |
gb = GridOptionsBuilder.from_dataframe(dataset_df)
|
150 |
+
gb.configure_default_column(sortable=False)
|
151 |
gb.configure_column(
|
152 |
"model_id",
|
153 |
cellRenderer=JsCode('''function(params) {return '<a target="_blank" href="https://huggingface.co/'+params.value+'">'+params.value+'</a>'}'''),
|
|
|
156 |
gb.configure_column(name, type=["numericColumn","numberColumnFilter","customNumericFormat"], precision=2, aggFunc='sum')
|
157 |
|
158 |
gb.configure_column(
|
159 |
+
sorting_metric,
|
160 |
+
sortable=True,
|
161 |
cellStyle=JsCode('''function(params) { return {'backgroundColor': '#FFD21E'}}''')
|
162 |
)
|
163 |
|