tangtang commited on
Commit
df6b6fb
·
1 Parent(s): 430b643

Update space1

Browse files
Files changed (1) hide show
  1. src/populate.py +15 -15
src/populate.py CHANGED
@@ -13,34 +13,34 @@ def get_leaderboard_df(results_path: str, requests_path: str, cols: list, benchm
13
  raw_data = get_raw_eval_results(results_path, requests_path)
14
  all_data_json = [v.to_dict() for v in raw_data]
15
  print(all_data_json)
 
16
  df = pd.DataFrame.from_records(all_data_json)
17
- print(df)
18
- df["Precision (%)"] = df["Precision (%)"].apply(lambda x: x[0] if len(x) > 0 else np.nan)
19
- df["Title search rate (%)"] = df["Title search rate (%)"].apply(lambda x: x[0] if len(x) > 0 else np.nan)
20
- df = df.sort_values(by=["Precision (%)"], ascending=False)
21
 
 
 
 
22
 
23
- # 假设用 Precision (%) 和 Title search rate (%) 的平均值
24
  df["Average ⬆️"] = df[["Precision (%)", "Title search rate (%)"]].mean(axis=1)
25
 
26
- # # 然后排序
27
  df = df.sort_values(by=["Average ⬆️"], ascending=False)
28
- print(df.head(10))
29
- # 再保留需要显示的列
30
  cols = [c for c in cols if c in df.columns]
31
  df = df[cols].round(2)
32
 
33
- # df = df[cols].round(decimals=2)
 
 
 
34
 
35
- # filter out if any of the benchmarks have not been produced
36
- #处理nan值
37
- df = df.fillna(0)
38
-
39
- df = df[has_no_nan_values(df, benchmark_cols)]
40
-
41
  return df
42
 
43
 
 
44
  def get_evaluation_queue_df(save_path: str, cols: list) -> list[pd.DataFrame]:
45
  """Creates the different dataframes for the evaluation queues requestes"""
46
  entries = [entry for entry in os.listdir(save_path) if not entry.startswith(".")]
 
13
  raw_data = get_raw_eval_results(results_path, requests_path)
14
  all_data_json = [v.to_dict() for v in raw_data]
15
  print(all_data_json)
16
+
17
  df = pd.DataFrame.from_records(all_data_json)
18
+ # print(df.head(10))
 
 
 
19
 
20
+ # 将数组转标量,空数组变为 0
21
+ df["Precision (%)"] = df["Precision (%)"].apply(lambda x: x[0] if len(x) > 0 else 0)
22
+ df["Title search rate (%)"] = df["Title search rate (%)"].apply(lambda x: x[0] if len(x) > 0 else 0)
23
 
24
+ # 平均值列
25
  df["Average ⬆️"] = df[["Precision (%)", "Title search rate (%)"]].mean(axis=1)
26
 
27
+ # 排序
28
  df = df.sort_values(by=["Average ⬆️"], ascending=False)
29
+
30
+ # 保留需要显示的列
31
  cols = [c for c in cols if c in df.columns]
32
  df = df[cols].round(2)
33
 
34
+ # 如果 benchmark_cols 有列不在 df 中,忽略
35
+ benchmark_cols = [c for c in benchmark_cols if c in df.columns]
36
+ if benchmark_cols:
37
+ df = df[has_no_nan_values(df, benchmark_cols)]
38
 
39
+ print(df.head(10))
 
 
 
 
 
40
  return df
41
 
42
 
43
+
44
  def get_evaluation_queue_df(save_path: str, cols: list) -> list[pd.DataFrame]:
45
  """Creates the different dataframes for the evaluation queues requestes"""
46
  entries = [entry for entry in os.listdir(save_path) if not entry.startswith(".")]