mlverse / tft

R implementation of Temporal Fusion Transformers
https://mlverse.github.io/tft/
Other
25 stars 9 forks source link

Error if spec_covariate_known is not supplied #40

Closed vidarsumo closed 1 year ago

vidarsumo commented 1 year ago

Is there a reason why spec_covariate_known() is required?

From your Getting started

This works:

tft_dataset_spec(rec, train) %>% 
  spec_covariate_index(date) %>% 
  spec_covariate_key(system) %>%
  spec_covariate_known(time_since_begining, starts_with("date_")) %>% 
  spec_time_splits(lookback = 5*12, horizon = 12) %>% 
  prep()

This doesn't:

tft_dataset_spec(rec, train) %>% 
  spec_covariate_index(date) %>% 
  spec_covariate_key(system) %>%
  #spec_covariate_known(time_since_begining, starts_with("date_")) %>% 
  spec_time_splits(lookback = 5*12, horizon = 12) %>% 
  prep()

  Error in `purrr::map2()`:
! Can't recycle `.x` (size 0) to match `.y` (size 2).

I have a univariate time series which does not have any known covariates for the future and including day of month, week of year is of no use in my example. This is not possible as of now so I have to create, say, week of year and include it in my model even though I know this is of no use.

dfalbel commented 1 year ago

This is probably a bug as there is no problem in not having it theoretically. Although it's probably recommended to always pass at least a linearly increasing value to mark the time series trend.

vidarsumo commented 1 year ago

Ok got it.