ziyuzhou02 commited on
Commit
7f951ea
·
verified ·
1 Parent(s): 633eed0

Fix Space startup: sync full app source

Browse files
Files changed (1) hide show
  1. src/utils.py +27 -3
src/utils.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import os
2
  import re
3
  from pathlib import Path
@@ -77,14 +78,37 @@ def unify_freq(df: pd.DataFrame) -> pd.DataFrame:
77
  return df
78
 
79
 
80
- def prepare_metrics_df(df: pd.DataFrame) -> pd.DataFrame:
81
- """Clean metric columns for aggregation (GIFT-Eval style, no model normalization)."""
 
 
 
 
 
 
 
 
82
  df = df.copy()
83
  df["model"] = df["model"].replace(LEGACY_MODEL_NAMES)
84
 
85
  for metric in METRIC_COLUMNS:
86
  df[metric] = pd.to_numeric(df[metric], errors="coerce")
87
  df[metric] = df[metric].fillna(df[metric].mean())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  return df
89
 
90
 
@@ -137,7 +161,7 @@ def get_grouped_dfs(
137
 
138
  df = load_all_results(root_dir)
139
  df = enrich_with_properties(df, ds_properties)
140
- df = prepare_metrics_df(df)
141
  df = _add_per_dataset_ranks(df)
142
 
143
  rank_cols = [f"Rank_{metric}" for metric in DISPLAY_METRICS]
 
1
+ import json
2
  import os
3
  import re
4
  from pathlib import Path
 
78
  return df
79
 
80
 
81
+ def load_baseline_name(root_dir: str = "results") -> str:
82
+ status_path = Path(root_dir) / "online_status.json"
83
+ if status_path.exists():
84
+ baseline = json.loads(status_path.read_text()).get("baseline_model")
85
+ if baseline:
86
+ return baseline
87
+ return "Chronos-Bolt-Base"
88
+
89
+
90
+ def standardize_df(df: pd.DataFrame, root_dir: str = "results") -> pd.DataFrame:
91
  df = df.copy()
92
  df["model"] = df["model"].replace(LEGACY_MODEL_NAMES)
93
 
94
  for metric in METRIC_COLUMNS:
95
  df[metric] = pd.to_numeric(df[metric], errors="coerce")
96
  df[metric] = df[metric].fillna(df[metric].mean())
97
+
98
+ baseline_name = load_baseline_name(root_dir)
99
+ if baseline_name not in set(df["model"]):
100
+ return df
101
+
102
+ group_keys = ["dataset", "term_length", "frequency"]
103
+ for _, group in df.groupby(group_keys):
104
+ baseline = group[group["model"] == baseline_name]
105
+ if baseline.empty:
106
+ continue
107
+ idx = baseline.index[0]
108
+ for metric in METRIC_COLUMNS:
109
+ denom = baseline.at[idx, metric]
110
+ if denom and denom != 0:
111
+ df.loc[group.index, metric] = df.loc[group.index, metric] / denom
112
  return df
113
 
114
 
 
161
 
162
  df = load_all_results(root_dir)
163
  df = enrich_with_properties(df, ds_properties)
164
+ df = standardize_df(df, root_dir)
165
  df = _add_per_dataset_ranks(df)
166
 
167
  rank_cols = [f"Rank_{metric}" for metric in DISPLAY_METRICS]