ziyuzhou02 commited on
Commit
8a8647b
·
verified ·
1 Parent(s): 9f9117d

Deploy Space: update src

Browse files
Files changed (1) hide show
  1. src/utils.py +21 -2
src/utils.py CHANGED
@@ -83,6 +83,19 @@ RESULT_COLUMNS = [
83
  "num_variates",
84
  ]
85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  GIFT_AGGREGATE_FILES = {
87
  "prediction_length": "results_by_prediction_length.csv",
88
  "domain": "results_by_domain.csv",
@@ -140,7 +153,7 @@ def load_all_results(root_dir: str = "results") -> pd.DataFrame:
140
  for file in files:
141
  if file != "all_results.csv":
142
  continue
143
- frame = pd.read_csv(os.path.join(subdir, file))
144
  if frame.empty:
145
  continue
146
  frames.append(frame)
@@ -480,6 +493,7 @@ DOMAIN_DISPLAY = {
480
  "Weather": "Climate",
481
  "Air Quality": "Climate",
482
  "Transport": "Transport",
 
483
  "Finance": "Finance",
484
  "Ocean": "Ocean",
485
  "Hydrology": "Hydrology",
@@ -500,6 +514,9 @@ DATASET_SHORT_NAMES = {
500
  "usgs_earthquake_all_week_hourly_earthquake_count": "Earthquake count",
501
  "usgs_potomac_iv_usgs_00060": "Potomac river flow",
502
  "wikimedia_time_series_hourly_pageviews": "Wikipedia pageviews",
 
 
 
503
  }
504
 
505
 
@@ -534,7 +551,7 @@ def lookup_dataset_domain(dataset: str, root_dir: str = "results") -> str:
534
  if not csv_path.exists():
535
  continue
536
  try:
537
- df = pd.read_csv(csv_path)
538
  if "domain" not in df.columns or "dataset" not in df.columns:
539
  continue
540
  # dataset column in all_results is "dataset_id/freq/term", strip suffix
@@ -553,6 +570,7 @@ DOMAIN_TAB_ORDER = [
553
  "Ocean",
554
  "Hydrology",
555
  "Transport",
 
556
  "Hazards",
557
  "Web",
558
  "Other",
@@ -872,6 +890,7 @@ DOMAIN_COLORS = {
872
  "Ocean": "#34d399",
873
  "Hydrology": "#818cf8",
874
  "Transport": "#fbbf24",
 
875
  "Hazards": "#fb7185",
876
  "Web": "#a78bfa",
877
  "Other": "#94a3b8",
 
83
  "num_variates",
84
  ]
85
 
86
+
87
+ def _read_result_csv(path: str | Path) -> pd.DataFrame:
88
+ df = pd.read_csv(
89
+ path,
90
+ usecols=lambda column: column in RESULT_COLUMNS,
91
+ index_col=False,
92
+ )
93
+ missing = [column for column in RESULT_COLUMNS if column not in df.columns]
94
+ if missing:
95
+ raise ValueError(f"{path} is missing required result columns: {missing}")
96
+ return df
97
+
98
+
99
  GIFT_AGGREGATE_FILES = {
100
  "prediction_length": "results_by_prediction_length.csv",
101
  "domain": "results_by_domain.csv",
 
153
  for file in files:
154
  if file != "all_results.csv":
155
  continue
156
+ frame = _read_result_csv(os.path.join(subdir, file))
157
  if frame.empty:
158
  continue
159
  frames.append(frame)
 
493
  "Weather": "Climate",
494
  "Air Quality": "Climate",
495
  "Transport": "Transport",
496
+ "Transportation": "Transportation",
497
  "Finance": "Finance",
498
  "Ocean": "Ocean",
499
  "Hydrology": "Hydrology",
 
514
  "usgs_earthquake_all_week_hourly_earthquake_count": "Earthquake count",
515
  "usgs_potomac_iv_usgs_00060": "Potomac river flow",
516
  "wikimedia_time_series_hourly_pageviews": "Wikipedia pageviews",
517
+ "data_gov_sg_singapore_rainfall_5min_rainfall_5min_total": "Singapore rainfall",
518
+ "data_gov_sg_singapore_taxi_availability_available_taxi_count": "Singapore available taxis",
519
+ "data_gov_sg_sgx_equities_turnover_monthly_turnover_value_million_sgd": "SGX equities turnover",
520
  }
521
 
522
 
 
551
  if not csv_path.exists():
552
  continue
553
  try:
554
+ df = _read_result_csv(csv_path)
555
  if "domain" not in df.columns or "dataset" not in df.columns:
556
  continue
557
  # dataset column in all_results is "dataset_id/freq/term", strip suffix
 
570
  "Ocean",
571
  "Hydrology",
572
  "Transport",
573
+ "Transportation",
574
  "Hazards",
575
  "Web",
576
  "Other",
 
890
  "Ocean": "#34d399",
891
  "Hydrology": "#818cf8",
892
  "Transport": "#fbbf24",
893
+ "Transportation": "#14b8a6",
894
  "Hazards": "#fb7185",
895
  "Web": "#a78bfa",
896
  "Other": "#94a3b8",