business-science / modeltime.h2o

Forecasting with H2O AutoML. Use the H2O Automatic Machine Learning algorithm as a backend for Modeltime Time Series Forecasting.

Home Page:https://business-science.github.io/modeltime.h2o/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problems with Date

alexeks opened this issue · comments

Modeltimeh2o error is

Error in .h2o.doSafeREST(h2oRestApiVersion = h2oRestApiVersion, urlSuffix = page, :
ERROR MESSAGE:
Provided column type POSIXct is unknown. Cannot proceed with parse due to invalid argument.

If the Date is passed as a date (without minutes ann seconds) there is no error message

h2o code itself is running with minutes and seconds with no problems.
Both codes are below. The data file is attached.

library(modeltime)
library(modeltime.h2o)
library(modeltime.resample)
library(modeltime.ensemble)
library(timetk)
library(tidymodels)
library(tidyverse)
library(dplyr)
library(tidyr)
library(lubridate)
h20.csv

#h2o code without modeltime h2o
h2o.init(
nthreads = -1,
ip = 'localhost',
port = 54321
)

h2odf1<-h2o.importFile("C:/City of Chico/h20.csv")

aml <- h2o.automl(x = "Date", y = "total",
training_frame = h2odf1,
max_models = 20,
seed = 1)

lb <- aml@leaderboard
print(lb, n = nrow(lb))
#modeltime h2o code#################
h2o.init(
nthreads = -1,
ip = 'localhost',
port = 54321
)

model_spec <- automl_reg(mode = 'regression') %>%
set_engine(
engine = 'h2o',
max_runtime_secs = 5,
max_runtime_secs_per_model = 3,
max_models = 3,
nfolds = 5,
exclude_algos = c("DeepLearning"),
verbosity = NULL,
seed = 786
)

model_fitted1 <- model_spec %>%
fit(total ~ Date,data=as.data.frame(h2odf1))

Will take a look and let you know.

Modeltimeh2o error is

Error in .h2o.doSafeREST(h2oRestApiVersion = h2oRestApiVersion, urlSuffix = page, : ERROR MESSAGE: Provided column type POSIXct is unknown. Cannot proceed with parse due to invalid argument.
If the Date is passed as a date (without minutes ann seconds) there is no error message

h2o code itself is running with minutes and seconds with no problems.

Both codes are below. The data file is attached.
library(modeltime)
library(modeltime.h2o)
library(modeltime.resample)
library(modeltime.ensemble)
library(timetk)
library(tidymodels)
library(tidyverse)
library(dplyr)
library(tidyr)
library(lubridate)
h20.csv

#h2o code without modeltime h2o
h2o.init(
nthreads = -1,
ip = 'localhost',
port = 54321
)

h2odf1<-h2o.importFile("C:/City of Chico/h20.csv")

aml <- h2o.automl(x = "Date", y = "total",
training_frame = h2odf1,
max_models = 20,
seed = 1)

lb <- aml@leaderboard
print(lb, n = nrow(lb))
#modeltime h2o code#################
h2o.init(
nthreads = -1,
ip = 'localhost',
port = 54321
)

model_spec <- automl_reg(mode = 'regression') %>%
set_engine(
engine = 'h2o',
max_runtime_secs = 5,
max_runtime_secs_per_model = 3,
max_models = 3,
nfolds = 5,
exclude_algos = c("DeepLearning"),
verbosity = NULL,
seed = 786
)

model_fitted1 <- model_spec %>%
fit(total ~ Date,data=as.data.frame(h2odf1))

you can try
h2odf1_rev <- h2odf1 %>% mutate(Date = as.Date(Date))

then, you use that dataframe in this syntax
model_fitted1 <- model_spec %>% fit(total ~ Date, data=h2odf1_rev)