Skip to content
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

Dials Helpers: Create tuning functions for specifications #14

Open
mdancho84 opened this issue Dec 30, 2020 · 2 comments
Open

Dials Helpers: Create tuning functions for specifications #14

mdancho84 opened this issue Dec 30, 2020 · 2 comments

Comments

@mdancho84
Copy link
Contributor

mdancho84 commented Dec 30, 2020

Problem

Code like this fails.

model_spec_deepar_tune <- deep_ar(
    id                    = "id",
    freq                  = "W",
    prediction_length     = 12,
    lookback_length       = tune(),
    num_batches_per_epoch = tune(),
    epochs                = 2,
    cell_type             = "lstm"
) %>%
    set_engine("gluonts_deepar")

gluonts_grid <- expand_grid(
    lookback_length = c(12, 18, 24, 36),
    num_batches_per_epoch = c(10, 25, 35, 50)
    )
wflw_deep_tune <- workflow() %>%
    add_model(model_spec_deepar_tune) %>%
    add_recipe(recipe_spec_gluon)
deep_ar_tune <- tune_grid(
    wflw_deep_tune,
    resamples = resamples_tscv,
    param_info = NULL,
    grid = gluonts_grid,
    control = control_grid(verbose = TRUE)
)

Error Returned:

Error when calling lookback_length(): Error : 'lookback_length' is not an exported object from 'namespace:modeltime.gluonts'

Proposed Solution

Create dials functions for tuning parameters.

@flrs
Copy link
Contributor

flrs commented Feb 23, 2021

Where would those functions have to be created? Here in modeltime.gluonts or over at https://github.com/tidymodels/dials/?

@mdancho84
Copy link
Contributor Author

Hey @flrs , the way I would do it is in the modeltime.gluonts package by creating a file named: dials-deepar_params.R and adding the missing functions.

An example is in modeltime for dials-prophet_params.R: https://github.com/business-science/modeltime/blob/master/R/dials-prophet_params.R

We need to be careful because we don't want to overwrite other dials parameters that may exist. Otherwise, I'll get hate-mail saying my function is overwriting another tidymodels or R package's function. A few packages we can review are:

The important thing is to either use the same function as a common dials package or to create something new that others won't overwrite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants