-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
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
Cannot tune ets_model and loss arguments in adam_reg() function. #225
Comments
mdancho84
added a commit
that referenced
this issue
Oct 22, 2024
I've fixed this in the development version of modeltime. Install: remotes::isntall_github("business-science/modeltime") Reproducible example: library(dplyr)
library(parsnip)
library(rsample)
library(timetk)
library(modeltime)
library(smooth)
m750 <- m4_monthly %>% filter(id == "M750")
set.seed(1234)
splits <- initial_time_split(m750, prop = 0.8)
set.seed(456)
time_roll <-
rolling_origin(
data = training(splits),
initial = round(nrow(training(splits)) * 0.75),
assess = 24,
cumulative = TRUE,
skip = TRUE
)
# recipe
rec <- recipe(value ~ date, data = training(splits)) %>%
step_log(value)
# Model Spec
model_spec <-
modeltime::adam_reg(
# ets_model = tune("ets"),
loss = tune()
) %>%
set_engine('adam')
# selecting terms to be tuned
ets_params <-
crossing(
error = c("A", "M"),
trend = c("N", "A", "Ad", "M", "Md"),
seasonality = c("N", "A", "M")
) %>%
mutate(comb = paste0(error, trend, seasonality)) %>%
pull(comb) %>%
sample(2) # randomly selecting 2 ets terms to be tuned
loss_params <-
c("likelihood", "MSE", "MAE", "HAM", "LASSO",
"RIDGE", "MSEh", "TMSE", "GTMSE", "MSCE") %>%
sample(2) # randomly selecting 2 loss terms to be tuned
grid_1 <- crossing(
# ets_model = ets_params,
loss = loss_params
)
# tuning the model
adam_fit <-
workflow() %>%
add_model(model_spec) %>%
add_recipe(rec) %>%
tune_grid(
resamples = time_roll,
metrics = metric_set(rmse, rsq),
grid = grid_1
) Output:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am teaching myself how this function works by tuning it. I may be mistaken, but I do not think ets and loss arguments should be present in a model that is based on ARIMA. Again I may be wrong.
I was trying to tune these parameters and it trows errors as seen in the code below. PS. thanks for your contributions!!
library(dplyr)
library(parsnip)
library(rsample)
library(timetk)
library(modeltime)
library(smooth)
Data
m750 <- m4_monthly %>% filter(id == "M750")
Split Data 80/20
set.seed(1234)
splits <- initial_time_split(m750, prop = 0.8)
set.seed(456)
time_roll <-
rolling_origin(
data = training(splits),
initial = round(nrow(training(splits)) * 0.75),
assess = 24,
cumulative = TRUE,
skip = TRUE
)
recipe
rec <- recipe(value ~ date, data = training(splits)) %>%
step_log(value)
Model Spec
model_spec <-
modeltime::adam_reg(
ets_model = tune("ets"),
# loss = tune("loss")
) %>%
set_engine('adam')
selecting terms to be tuned
ets_params <-
crossing(
error = c("A", "M"),
trend = c("N", "A", "Ad", "M", "Md"),
seasonality = c("N", "A", "M")
) %>%
mutate(comb = paste0(error, trend, seasonality)) %>%
pull(comb) %>%
sample(2) # randomly selecting 2 ets terms to be tuned
loss_params <-
c("likelihood", "MSE", "MAE", "HAM", "LASSO",
"RIDGE", "MSEh", "TMSE", "GTMSE", "MSCE") %>%
sample(2) # randomly selecting 2 loss terms to be tuned
tuning the model
adam_fit <-
workflow() %>%
add_model(model_spec) %>%
add_recipe(rec) %>%
tune_grid(
resamples = time_roll,
metrics = metric_set(rmse, rsq),
grid = crossing(
ets = loss_params,
)
)
the error
The text was updated successfully, but these errors were encountered: