kashif HF staff commited on
Commit
8417fdd
1 Parent(s): 58aafbe

update hourly prediction lengths

Browse files

take prediction lengths from official experiments https://github.com/rakshitha123/TSForecasting/blob/master/experiments/deep_learning_experiments.py

Files changed (1) hide show
  1. monash_tsf.py +38 -11
monash_tsf.py CHANGED
@@ -121,6 +121,7 @@ class MonashTSF(datasets.GeneratorBasedBuilder):
121
  description="5 time series representing the half hourly electricity demand of 5 states in Australia: Victoria, New South Wales, Queensland, Tasmania and South Australia.",
122
  url="https://zenodo.org/record/4659727",
123
  file_name="australian_electricity_demand_dataset.zip",
 
124
  ),
125
  MonashTSFBuilderConfig(
126
  name="wind_farms_minutely",
@@ -142,6 +143,7 @@ class MonashTSF(datasets.GeneratorBasedBuilder):
142
  description="Hourly pedestrian counts captured from 66 sensors in Melbourne city starting from May 2009.",
143
  url="https://zenodo.org/record/4656626",
144
  file_name="pedestrian_counts_dataset.zip",
 
145
  ),
146
  MonashTSFBuilderConfig(
147
  name="vehicle_trips",
@@ -191,6 +193,7 @@ class MonashTSF(datasets.GeneratorBasedBuilder):
191
  description="137 time series representing the solar power production recorded per every 10 minutes in Alabama state in 2006.",
192
  url="https://zenodo.org/record/4656144",
193
  file_name="solar_10_minutes_dataset.zip",
 
194
  ),
195
  MonashTSFBuilderConfig(
196
  name="solar_weekly",
@@ -198,6 +201,7 @@ class MonashTSF(datasets.GeneratorBasedBuilder):
198
  description="137 time series representing the weekly solar power production in Alabama state in 2006.",
199
  url="https://zenodo.org/record/4656151",
200
  file_name="solar_weekly_dataset.zip",
 
201
  ),
202
  MonashTSFBuilderConfig(
203
  name="car_parts",
@@ -399,10 +403,14 @@ class MonashTSF(datasets.GeneratorBasedBuilder):
399
  features = datasets.Features(
400
  {
401
  "start": datasets.Value("timestamp[s]"),
402
- "target": datasets.Sequence(datasets.Sequence(datasets.Value("float32"))),
 
 
403
  "feat_static_cat": datasets.Sequence(datasets.Value("uint64")),
404
  # "feat_static_real": datasets.Sequence(datasets.Value("float32")),
405
- "feat_dynamic_real": datasets.Sequence(datasets.Sequence(datasets.Value("float32"))),
 
 
406
  # "feat_dynamic_cat": datasets.Sequence(datasets.Sequence(datasets.Value("uint64"))),
407
  "item_id": datasets.Value("string"),
408
  }
@@ -414,7 +422,9 @@ class MonashTSF(datasets.GeneratorBasedBuilder):
414
  "target": datasets.Sequence(datasets.Value("float32")),
415
  "feat_static_cat": datasets.Sequence(datasets.Value("uint64")),
416
  # "feat_static_real": datasets.Sequence(datasets.Value("float32")),
417
- "feat_dynamic_real": datasets.Sequence(datasets.Sequence(datasets.Value("float32"))),
 
 
418
  # "feat_dynamic_cat": datasets.Sequence(datasets.Sequence(datasets.Value("uint64"))),
419
  "item_id": datasets.Value("string"),
420
  }
@@ -474,7 +484,7 @@ class MonashTSF(datasets.GeneratorBasedBuilder):
474
  prediction_length_map = {
475
  "S": 60,
476
  "T": 60,
477
- "H": 48,
478
  "D": 30,
479
  "W": 8,
480
  "M": 12,
@@ -496,13 +506,17 @@ class MonashTSF(datasets.GeneratorBasedBuilder):
496
  start = ts.start_timestamp[0]
497
 
498
  if self.config.target_fields is not None:
499
- target_fields = ts[ts[self.config.data_column].isin(self.config.target_fields)]
 
 
500
  else:
501
  target_fields = self.config.data_column.unique()
502
 
503
  if self.config.feat_dynamic_real_fields is not None:
504
  feat_dynamic_real_fields = ts[
505
- ts[self.config.data_column].isin(self.config.feat_dynamic_real_fields)
 
 
506
  ]
507
  feat_dynamic_real = np.vstack(feat_dynamic_real_fields.target)
508
  else:
@@ -513,7 +527,10 @@ class MonashTSF(datasets.GeneratorBasedBuilder):
513
  feat_static_cat = [cat]
514
 
515
  if split in ["train", "val"]:
516
- offset = forecast_horizon * self.config.rolling_evaluations + forecast_horizon * (split == "train")
 
 
 
517
  target = target[..., :-offset]
518
  if self.config.feat_dynamic_real_fields is not None:
519
  feat_dynamic_real = feat_dynamic_real[..., :-offset]
@@ -527,18 +544,25 @@ class MonashTSF(datasets.GeneratorBasedBuilder):
527
  }
528
  else:
529
  if self.config.target_fields is not None:
530
- target_fields = loaded_data[loaded_data[self.config.data_column].isin(self.config.target_fields)]
 
 
531
  else:
532
  target_fields = loaded_data
533
  if self.config.feat_dynamic_real_fields is not None:
534
  feat_dynamic_real_fields = loaded_data[
535
- loaded_data[self.config.data_column].isin(self.config.feat_dynamic_real_fields)
 
 
536
  ]
537
  else:
538
  feat_dynamic_real_fields = None
539
 
540
  for cat, ts in target_fields.iterrows():
541
- start = ts.get("start_timestamp", datetime.strptime("1900-01-01 00-00-00", "%Y-%m-%d %H-%M-%S"))
 
 
 
542
  target = ts.target
543
  if feat_dynamic_real_fields is not None:
544
  feat_dynamic_real = np.vstack(feat_dynamic_real_fields.target)
@@ -552,7 +576,10 @@ class MonashTSF(datasets.GeneratorBasedBuilder):
552
  item_id = ts.series_name
553
 
554
  if split in ["train", "val"]:
555
- offset = forecast_horizon * self.config.rolling_evaluations + forecast_horizon * (split == "train")
 
 
 
556
  target = target[..., :-offset]
557
  if feat_dynamic_real is not None:
558
  feat_dynamic_real = feat_dynamic_real[..., :-offset]
 
121
  description="5 time series representing the half hourly electricity demand of 5 states in Australia: Victoria, New South Wales, Queensland, Tasmania and South Australia.",
122
  url="https://zenodo.org/record/4659727",
123
  file_name="australian_electricity_demand_dataset.zip",
124
+ prediction_length=336,
125
  ),
126
  MonashTSFBuilderConfig(
127
  name="wind_farms_minutely",
 
143
  description="Hourly pedestrian counts captured from 66 sensors in Melbourne city starting from May 2009.",
144
  url="https://zenodo.org/record/4656626",
145
  file_name="pedestrian_counts_dataset.zip",
146
+ prediction_length=24,
147
  ),
148
  MonashTSFBuilderConfig(
149
  name="vehicle_trips",
 
193
  description="137 time series representing the solar power production recorded per every 10 minutes in Alabama state in 2006.",
194
  url="https://zenodo.org/record/4656144",
195
  file_name="solar_10_minutes_dataset.zip",
196
+ prediction_length=1008,
197
  ),
198
  MonashTSFBuilderConfig(
199
  name="solar_weekly",
 
201
  description="137 time series representing the weekly solar power production in Alabama state in 2006.",
202
  url="https://zenodo.org/record/4656151",
203
  file_name="solar_weekly_dataset.zip",
204
+ prediction_length=5,
205
  ),
206
  MonashTSFBuilderConfig(
207
  name="car_parts",
 
403
  features = datasets.Features(
404
  {
405
  "start": datasets.Value("timestamp[s]"),
406
+ "target": datasets.Sequence(
407
+ datasets.Sequence(datasets.Value("float32"))
408
+ ),
409
  "feat_static_cat": datasets.Sequence(datasets.Value("uint64")),
410
  # "feat_static_real": datasets.Sequence(datasets.Value("float32")),
411
+ "feat_dynamic_real": datasets.Sequence(
412
+ datasets.Sequence(datasets.Value("float32"))
413
+ ),
414
  # "feat_dynamic_cat": datasets.Sequence(datasets.Sequence(datasets.Value("uint64"))),
415
  "item_id": datasets.Value("string"),
416
  }
 
422
  "target": datasets.Sequence(datasets.Value("float32")),
423
  "feat_static_cat": datasets.Sequence(datasets.Value("uint64")),
424
  # "feat_static_real": datasets.Sequence(datasets.Value("float32")),
425
+ "feat_dynamic_real": datasets.Sequence(
426
+ datasets.Sequence(datasets.Value("float32"))
427
+ ),
428
  # "feat_dynamic_cat": datasets.Sequence(datasets.Sequence(datasets.Value("uint64"))),
429
  "item_id": datasets.Value("string"),
430
  }
 
484
  prediction_length_map = {
485
  "S": 60,
486
  "T": 60,
487
+ "H": 168,
488
  "D": 30,
489
  "W": 8,
490
  "M": 12,
 
506
  start = ts.start_timestamp[0]
507
 
508
  if self.config.target_fields is not None:
509
+ target_fields = ts[
510
+ ts[self.config.data_column].isin(self.config.target_fields)
511
+ ]
512
  else:
513
  target_fields = self.config.data_column.unique()
514
 
515
  if self.config.feat_dynamic_real_fields is not None:
516
  feat_dynamic_real_fields = ts[
517
+ ts[self.config.data_column].isin(
518
+ self.config.feat_dynamic_real_fields
519
+ )
520
  ]
521
  feat_dynamic_real = np.vstack(feat_dynamic_real_fields.target)
522
  else:
 
527
  feat_static_cat = [cat]
528
 
529
  if split in ["train", "val"]:
530
+ offset = (
531
+ forecast_horizon * self.config.rolling_evaluations
532
+ + forecast_horizon * (split == "train")
533
+ )
534
  target = target[..., :-offset]
535
  if self.config.feat_dynamic_real_fields is not None:
536
  feat_dynamic_real = feat_dynamic_real[..., :-offset]
 
544
  }
545
  else:
546
  if self.config.target_fields is not None:
547
+ target_fields = loaded_data[
548
+ loaded_data[self.config.data_column].isin(self.config.target_fields)
549
+ ]
550
  else:
551
  target_fields = loaded_data
552
  if self.config.feat_dynamic_real_fields is not None:
553
  feat_dynamic_real_fields = loaded_data[
554
+ loaded_data[self.config.data_column].isin(
555
+ self.config.feat_dynamic_real_fields
556
+ )
557
  ]
558
  else:
559
  feat_dynamic_real_fields = None
560
 
561
  for cat, ts in target_fields.iterrows():
562
+ start = ts.get(
563
+ "start_timestamp",
564
+ datetime.strptime("1900-01-01 00-00-00", "%Y-%m-%d %H-%M-%S"),
565
+ )
566
  target = ts.target
567
  if feat_dynamic_real_fields is not None:
568
  feat_dynamic_real = np.vstack(feat_dynamic_real_fields.target)
 
576
  item_id = ts.series_name
577
 
578
  if split in ["train", "val"]:
579
+ offset = (
580
+ forecast_horizon * self.config.rolling_evaluations
581
+ + forecast_horizon * (split == "train")
582
+ )
583
  target = target[..., :-offset]
584
  if feat_dynamic_real is not None:
585
  feat_dynamic_real = feat_dynamic_real[..., :-offset]