We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using target encoding in the recipe (step_lencode_mixed or step_lencode_glm) will return an error when calling modeltime_forecast(),
modeltime_forecast()
# 1.0.0 Setup --------------------------------------------------------------------------------- library(modeltime) library(tidymodels) library(tidyverse) library(embed) library(timetk) data_tbl <- walmart_sales_weekly %>% select(id, Dept, Date, Weekly_Sales) %>% set_names("id", "dept", "date", "outcome") %>% mutate(dept = paste0("dept_", dept)) lag_function <- function(data) { data %>% group_by(id) %>% tk_augment_lags(.value = outcome, .lags = 1:12) %>% ungroup() } data_lag_tbl <- data_tbl %>% lag_function splits <- data_lag_tbl %>% time_series_split(date_var = date, assess = 12, cumulative = TRUE) train_data_tbl <- training(splits) test_data_tbl <- testing(splits) # 2.0.0 Modelling ----------------------------------------------------------------------------- # 2.1.0 Recipes ---- parsnip_recipe <- recipes::recipe(outcome ~ ., data = train_data_tbl) %>% embed::step_lencode_mixed(recipes::all_nominal_predictors(), outcome = dplyr::vars(outcome)) %>% step_timeseries_signature(date) %>% update_role(id, new_role = "indicator") %>% update_role(date, new_role = "date-field") %>% step_zv(all_predictors()) %>% step_rm(matches("(.xts$)|(.iso$)|(.lbl$)|(_wday)|(_day)|(hour)|(minute)|(second)|(am.pm)")) # 2.2.0 Fit model ---- xgb_spec <- boost_tree(mode = "regression") %>% set_engine("xgboost") # 2.2.1 Non-recusrive ---- xgb_mtbl <- workflow() %>% add_recipe(parsnip_recipe) %>% add_model(xgb_spec) %>% fit(train_data_tbl) %>% modeltime_table() # 2.2.2 Recusrive ---- xgb_recusrive_mtbl <- workflow() %>% add_recipe(parsnip_recipe) %>% add_model(xgb_spec) %>% fit(train_data_tbl) %>% recursive( id = "id", transform = lag_function, train_tail = panel_tail(train_data_tbl, "id", 12) ) %>% modeltime_table() # 2.3.0 Forecast ---- # 2.3.1 Works ---- xgb_fc_tbl <- xgb_mtbl %>% modeltime_forecast( new_data = test_data_tbl, actual_data = data_lag_tbl, keep_data = TRUE ) # 2.3.2 Fails ---- xgb_recursive_fc_tbl <- xgb_recusrive_mtbl %>% modeltime_forecast( new_data = test_data_tbl, actual_data = data_lag_tbl, keep_data = TRUE ) Error: Can't combine `..1$dept` <character> and `..2$dept` <double>. Error in `dplyr::filter()`: ℹ In argument: `.model_desc == "ACTUAL" | .key == "prediction"`. Caused by error: ! object '.key' not found Run `rlang::last_trace()` to see where the error occurred. Warning message: Unknown or uninitialised column: `.key`.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Using target encoding in the recipe (step_lencode_mixed or step_lencode_glm) will return an error when calling
modeltime_forecast()
,The text was updated successfully, but these errors were encountered: