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

Tune prophet within modeltime model #246

Open
Patrikios opened this issue Apr 25, 2024 · 2 comments
Open

Tune prophet within modeltime model #246

Patrikios opened this issue Apr 25, 2024 · 2 comments

Comments

@Patrikios
Copy link

As the documentation does not povide a an example for hyperparameter tuning a prophet model, I tired a simple snippet like follows:

 modeltime::prophet_reg(
    growth = growth(values = c("linear", "logistic")),
    changepoint_num = changepoint_num(range = c(0L, 50L), trans = NULL)
  ) |>
    parsnip::set_engine(
      engine = "prophet",
      holidays = generated_holidays
    ) |>
    fit(target_var ~ .,
        data = split_train
    )

which fails with

growth must be 'linear' or 'logistic'. Defaulting to 'linear'.
Disabling daily seasonality. Run prophet with daily.seasonality=TRUE to override this.
Fehler in m$n.changepoints + 1 : 
  nicht-numerisches Argument für binären Operator

Is this usage correc?

@joranE
Copy link
Contributor

joranE commented Apr 25, 2024

In general you specify a hyperparameter for tuning by passing, e.g. growth = tune(). There is a full walkthrough of the process here.

@FColicino
Copy link

FColicino commented May 8, 2024

Alternatively, you can use create_model_grid to create a list of model that you need to train.
Below the code:

library(modeltime)
library(tidymodels)


m750

models <- 
  grid_regular(
    changepoint_num(),
    growth(),
    levels = 3) |>
  create_model_grid(
    f_model_spec = prophet_reg,
    engine_name  = "prophet",
    mode         = "regression"
  ) |>
  select(.models) |>
  pull() # or pluck(1)

preprocessing <-
  list(basic_preproc = recipe(value ~ date, data = m750))
  
wf <- workflow_set(preproc = preprocessing,
                   models = models)

modeltime_fit_workflowset(wf, data = m750)

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

3 participants