Open ichsan2895 opened 3 years ago
I just ran the tutorial. I've increased the number of models slightly to improve results. It seems to run OK for me.
library(tidymodels)
library(modeltime.h2o)
library(tidyverse)
library(timetk)
data_tbl <- walmart_sales_weekly %>%
select(id, Date, Weekly_Sales)
splits <- time_series_split(data_tbl, assess = "3 month", cumulative = TRUE)
recipe_spec <- recipe(Weekly_Sales ~ ., data = training(splits)) %>%
step_timeseries_signature(Date)
train_tbl <- training(splits) %>% bake(prep(recipe_spec), .)
test_tbl <- testing(splits) %>% bake(prep(recipe_spec), .)
h2o.init(
nthreads = -1,
ip = 'localhost',
port = 54321
)
#> Connection successful!
#>
#> R is connected to the H2O cluster:
#> H2O cluster uptime: 3 minutes 24 seconds
#> H2O cluster timezone: America/New_York
#> H2O data parsing timezone: UTC
#> H2O cluster version: 3.32.0.1
#> H2O cluster version age: 6 months and 18 days !!!
#> H2O cluster name: H2O_started_from_R_mdancho_rvk435
#> H2O cluster total nodes: 1
#> H2O cluster total memory: 7.96 GB
#> H2O cluster total cores: 12
#> H2O cluster allowed cores: 12
#> H2O cluster healthy: TRUE
#> H2O Connection ip: localhost
#> H2O Connection port: 54321
#> H2O Connection proxy: NA
#> H2O Internal Security: FALSE
#> H2O API Extensions: Amazon S3, XGBoost, Algos, AutoML, Core V3, TargetEncoder, Core V4
#> R Version: R version 4.0.2 (2020-06-22)
#> Warning in h2o.clusterInfo():
#> Your H2O cluster version is too old (6 months and 18 days)!
#> Please download and install the latest version from http://h2o.ai/download/
# Optional - Turn off progress indicators during training runs
h2o.no_progress()
model_spec <- automl_reg(mode = 'regression') %>%
set_engine(
engine = 'h2o',
max_runtime_secs = 15,
max_runtime_secs_per_model = 15,
max_models = 10,
nfolds = 5,
exclude_algos = c("DeepLearning"),
verbosity = NULL,
seed = 786
)
model_fitted <- model_spec %>%
fit(Weekly_Sales ~ ., data = train_tbl)
modeltime_tbl <- modeltime_table(
model_fitted
)
modeltime_tbl
#> # Modeltime Table
#> # A tibble: 1 x 3
#> .model_id .model .model_desc
#> <int> <list> <chr>
#> 1 1 <fit[+]> H2O AUTOML - STACKEDENSEMBLE
modeltime_tbl %>%
modeltime_calibrate(test_tbl) %>%
modeltime_forecast(
new_data = test_tbl,
actual_data = data_tbl,
keep_data = TRUE
) %>%
group_by(id) %>%
plot_modeltime_forecast(
.facet_ncol = 2,
.interactive = FALSE
)
data_prepared_tbl <- bind_rows(train_tbl, test_tbl)
future_tbl <- data_prepared_tbl %>%
group_by(id) %>%
future_frame(.length_out = "1 year") %>%
ungroup()
#> .date_var is missing. Using: Date
future_prepared_tbl <- bake(prep(recipe_spec), future_tbl)
refit_tbl <- modeltime_tbl %>%
modeltime_refit(data_prepared_tbl)
refit_tbl %>%
modeltime_forecast(
new_data = future_prepared_tbl,
actual_data = data_prepared_tbl,
keep_data = TRUE
) %>%
group_by(id) %>%
plot_modeltime_forecast(
.facet_ncol = 2,
.interactive = FALSE
)
#> Converting to H2OFrame...
#> Warning: Expecting the following names to be in the data frame: .conf_hi, .conf_lo.
#> Proceeding with '.conf_interval_show = FALSE' to visualize the forecast without confidence intervals.
#> Alternatively, try using `modeltime_calibrate()` before forecasting to add confidence intervals.
Created on 2021-04-27 by the reprex package (v1.0.0)
Hello, recently, I know where the problem is...
In this example, we must select just 3 columns
data_tbl <- My_DF %>% select(id, Date, Value)
If we doesn't select 3 columns (so, all columns in My_DF
become data_tbl
)
It will be error like I said before
Error: Problem with filter() input ..1. x object '.key' not found i Input ..1 is `.model_desc == "ACTUAL" | .key == "prediction"
Please try this one :
data_tbl <- walmart_sales_weekly %>% select(id, Date, Weekly_Sales)
will be error if we remove %>% select(id, Date, Weekly_Sales)
I don't know, its bug or feature?
Will need to look into this.
I have followed this tutorial, but I got error in this syntax
https://www.business-science.io/code-tools/2021/03/15/introducing-modeltime-h2o.html
Error: Problem with
filter()
input..1
. x object '.key' not found i Input..1
is `.model_desc == "ACTUAL" | .key == "prediction"My software version Windows 10 Education 64 bit R = 3.6.3 (64 bit) H2O = 3.32.0.1 modeltime = 0.5.1 modeltime.h2o = 0.1.1