cdminix commited on
Commit
ad01db8
1 Parent(s): 4bc7be5

fix rounding

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -26,6 +26,7 @@ def filter_dfs(tags, lb):
26
  lb = f_b_df.copy()
27
  if tags and len(lb) > 0:
28
  lb = lb[lb["Tags"].apply(lambda x: any(tag in x for tag in tags))]
 
29
  return lb
30
 
31
  def change_mean(env, lb):
@@ -36,6 +37,7 @@ def change_mean(env, lb):
36
  else:
37
  mean_cols = [col for col in lb.columns if str(col) not in ["Mean", "Model", "Tags"]]
38
  lb["Mean"] = lb[mean_cols].mean(axis=1)
 
39
  return lb
40
 
41
  def restart_space():
@@ -132,6 +134,13 @@ except Exception:
132
  restart_space()
133
 
134
 
 
 
 
 
 
 
 
135
  results_df = pd.read_csv(EVAL_RESULTS_PATH + "/results.csv")
136
 
137
  agg_df = BenchmarkSuite.aggregate_df(results_df)
@@ -142,8 +151,6 @@ mean_cols = [col for col in agg_df.columns if str(col) not in ["Mean", "Environm
142
  agg_df["Mean"] = agg_df[mean_cols].mean(axis=1)
143
  # make sure mean is the first column
144
  agg_df = agg_df[["Mean"] + [col for col in agg_df.columns if col != "Mean"]]
145
- for col in agg_df.columns:
146
- agg_df[col] = agg_df[col].apply(lambda x: round(x, 2))
147
  agg_df["Tags"] = ""
148
  agg_df.reset_index(inplace=True)
149
  agg_df.rename(columns={"dataset": "Model"}, inplace=True)
@@ -161,9 +168,6 @@ benchmark_df.set_index("Model", inplace=True)
161
  benchmark_df["Mean"] = benchmark_df.mean(axis=1)
162
  # make sure mean is the first column
163
  benchmark_df = benchmark_df[["Mean"] + [col for col in benchmark_df.columns if col != "Mean"]]
164
- # round all
165
- for col in benchmark_df.columns:
166
- benchmark_df[col] = benchmark_df[col].apply(lambda x: round(x, 2))
167
  benchmark_df["Tags"] = ""
168
  benchmark_df.reset_index(inplace=True)
169
  benchmark_df.sort_values("Mean", ascending=False, inplace=True)
@@ -204,7 +208,7 @@ def init_leaderboard(dataframe):
204
  cols = list(dataframe.columns)
205
  cols.remove("Tags")
206
  return Leaderboard(
207
- value=dataframe,
208
  select_columns=SelectColumns(
209
  default_selection=cols,
210
  cant_deselect=["Model", "Mean"],
 
26
  lb = f_b_df.copy()
27
  if tags and len(lb) > 0:
28
  lb = lb[lb["Tags"].apply(lambda x: any(tag in x for tag in tags))]
29
+ lb = rounded_df(lb)
30
  return lb
31
 
32
  def change_mean(env, lb):
 
37
  else:
38
  mean_cols = [col for col in lb.columns if str(col) not in ["Mean", "Model", "Tags"]]
39
  lb["Mean"] = lb[mean_cols].mean(axis=1)
40
+ lb = rounded_df(lb)
41
  return lb
42
 
43
  def restart_space():
 
134
  restart_space()
135
 
136
 
137
+ def rounded_df(df):
138
+ df = df.copy()
139
+ for col in df.columns:
140
+ if isinstance(col.values[0], float):
141
+ df[col] = df[col].apply(lambda x: round(x, 2))
142
+ return df
143
+
144
  results_df = pd.read_csv(EVAL_RESULTS_PATH + "/results.csv")
145
 
146
  agg_df = BenchmarkSuite.aggregate_df(results_df)
 
151
  agg_df["Mean"] = agg_df[mean_cols].mean(axis=1)
152
  # make sure mean is the first column
153
  agg_df = agg_df[["Mean"] + [col for col in agg_df.columns if col != "Mean"]]
 
 
154
  agg_df["Tags"] = ""
155
  agg_df.reset_index(inplace=True)
156
  agg_df.rename(columns={"dataset": "Model"}, inplace=True)
 
168
  benchmark_df["Mean"] = benchmark_df.mean(axis=1)
169
  # make sure mean is the first column
170
  benchmark_df = benchmark_df[["Mean"] + [col for col in benchmark_df.columns if col != "Mean"]]
 
 
 
171
  benchmark_df["Tags"] = ""
172
  benchmark_df.reset_index(inplace=True)
173
  benchmark_df.sort_values("Mean", ascending=False, inplace=True)
 
208
  cols = list(dataframe.columns)
209
  cols.remove("Tags")
210
  return Leaderboard(
211
+ value=rounded_df(dataframe),
212
  select_columns=SelectColumns(
213
  default_selection=cols,
214
  cant_deselect=["Model", "Mean"],