ziyuzhou02 commited on
Commit
2f42574
·
verified ·
1 Parent(s): b2378e2

Restrict leaderboard to live TS-Bench datasets

Browse files
Files changed (1) hide show
  1. src/utils.py +25 -1
src/utils.py CHANGED
@@ -125,6 +125,25 @@ def _read_result_csv(path: str | Path) -> pd.DataFrame:
125
  return df
126
 
127
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  GIFT_AGGREGATE_FILES = {
129
  "prediction_length": "results_by_prediction_length.csv",
130
  "domain": "results_by_domain.csv",
@@ -231,6 +250,11 @@ def prepare_results_df(
231
  df = load_all_results(root_dir)
232
  if df.empty:
233
  return df
 
 
 
 
 
234
  if Path(ds_properties).exists():
235
  df = enrich_with_properties(df, ds_properties)
236
  if "domain" in df.columns:
@@ -577,7 +601,7 @@ def lookup_dataset_domain(dataset: str, root_dir: str = "results") -> str:
577
  props_path = Path(root_dir) / "dataset_properties.csv"
578
  if props_path.exists():
579
  props = pd.read_csv(props_path)
580
- match = props[props["dataset"].str.lower() == base.lower()]
581
  if not match.empty and "domain" in match.columns:
582
  return str(match.iloc[0]["domain"])
583
 
 
125
  return df
126
 
127
 
128
+ def _dataset_key(value: object) -> str:
129
+ return str(value).split("/")[0].strip().lower()
130
+
131
+
132
+ def _load_live_dataset_keys(ds_properties: str | Path | None) -> set[str]:
133
+ if ds_properties is None:
134
+ return set()
135
+ path = Path(ds_properties)
136
+ if not path.exists():
137
+ return set()
138
+ try:
139
+ props = pd.read_csv(path)
140
+ except (OSError, pd.errors.ParserError, pd.errors.EmptyDataError):
141
+ return set()
142
+ if "dataset" not in props.columns:
143
+ return set()
144
+ return {_dataset_key(value) for value in props["dataset"].dropna()}
145
+
146
+
147
  GIFT_AGGREGATE_FILES = {
148
  "prediction_length": "results_by_prediction_length.csv",
149
  "domain": "results_by_domain.csv",
 
250
  df = load_all_results(root_dir)
251
  if df.empty:
252
  return df
253
+ live_dataset_keys = _load_live_dataset_keys(ds_properties)
254
+ if live_dataset_keys:
255
+ df = df[df["dataset"].map(_dataset_key).isin(live_dataset_keys)].copy()
256
+ if df.empty:
257
+ return pd.DataFrame(columns=[*RESULT_COLUMNS, "frequency", "term_length"])
258
  if Path(ds_properties).exists():
259
  df = enrich_with_properties(df, ds_properties)
260
  if "domain" in df.columns:
 
601
  props_path = Path(root_dir) / "dataset_properties.csv"
602
  if props_path.exists():
603
  props = pd.read_csv(props_path)
604
+ match = props[props["dataset"].map(_dataset_key) == _dataset_key(base)]
605
  if not match.empty and "domain" in match.columns:
606
  return str(match.iloc[0]["domain"])
607