Closed spsanderson closed 4 years ago
Yes, this is because you are using Standard N-Beats, and you need Ensemble N-Beats, which accepts multiple lookback_lengths
. I've just updated modeltime.gluonts
to respond with an error telling you to switch engines. I've also updated the example on the website to use "gluonts_nbeats_ensemble", which is correct.
Here is working code.
library(modeltime.gluonts)
library(tidymodels)
library(tidyverse)
library(timetk)
data <- read_rds("~/Downloads/df_grouped_tbl 2")
data %>%
# filter(id %in% unique(id)[1:3]) %>%
plot_time_series(date, value, .facet_vars = id, .facet_ncol = 3)
forcast_horizon <- 30
new_data <- data %>%
# filter(id %in% unique(id)[1:3]) %>%
group_by(id) %>%
future_frame(.date_var = date, .length_out = forcast_horizon) %>%
ungroup()
model_fit_nbeats_ensemble <- nbeats(
id = "id",
freq = "D",
prediction_length = forcast_horizon,
lookback_length = c(forcast_horizon, 4*forcast_horizon),
epochs = 5,
num_batches_per_epoch = 20,
bagging_size = 1
) %>%
set_engine("gluonts_nbeats_ensemble") %>%
fit(value ~ date + id, data)
preds <- modeltime_table(
model_fit_nbeats_ensemble
) %>%
modeltime_forecast(new_data, actual_data = data, keep_data = TRUE)
preds %>%
filter(id %in% unique(id)[1:6]) %>%
group_by(id) %>%
plot_modeltime_forecast(
.facet_ncol = 3
)
Working now.
Is there a way to inverse the stardardized_vec to get the non-standardized predictions? Can we simply run standardized_inv_vec on the predictions?
The best way is to use a recipe. This preserves the transformation value. recipes::step_normalize()
, which actually performs center/scaling.
df_grouped_tbl.zip
I am using the conical example in the description file for the nbeats model. My data is attached. Here is a glimpse of the data which is similar to what you have in the example.
Here is the code I run which is the same:
Here is the python error that comes back:
Changing the value to an integer and not using the
standardize_vec()
function by instead usingn() %>% as.integer()
yields the same exact error.