business-science / modeltime

Modeltime unlocks time series forecast models and machine learning in one framework
https://business-science.github.io/modeltime/
Other
532 stars 82 forks source link

Error when tuning prophet #55

Closed tonyk7440 closed 3 years ago

tonyk7440 commented 3 years ago

Getting the following error when trying to use tune_grid with prophet. I think it is because the growth() parameter is translating to linear in the tuning grid.

Example code below

library(parsnip)
library(modeltime)
library(dials)

# 
spec_prophet <- prophet_reg(
  growth = tune(),
  changepoint_num = tune(),
  changepoint_range = tune(),
  seasonality_yearly = tune(),
  seasonality_weekly = tune(),
  seasonality_daily = FALSE,
  prior_scale_changepoints = tune(),
  prior_scale_seasonality = tune(),
  prior_scale_holidays = tune()) %>%
  set_engine("prophet") %>%
  set_mode(mode = "regression")

# 
prophet_grid_spec <- grid_latin_hypercube(
  parameters(
    growth(),
    changepoint_range(),
    changepoint_num(), 
    seasonality_yearly(),
    seasonality_weekly(),
    prior_scale_changepoints(),
    prior_scale_seasonality(),
    prior_scale_holidays()),
  size = 10)

prophet_grid_spec

# A tibble: 10 x 8
   linear  changepoint_range changepoint_num seasonality_year~ seasonality_week~ prior_scale_changep~ prior_scale_seaso~ prior_scale_holi~
   <chr>               <dbl>           <int> <lgl>             <lgl>                            <dbl>              <dbl>             <dbl>
 1 linear              0.771               9 FALSE             TRUE                           0.00247            2.73              0.494  
 2 linear              0.642              22 TRUE              TRUE                           0.537              0.0290           56.4    
 3 logist~             0.888              42 FALSE             FALSE                          0.0785             0.128             0.00777
 4 linear              0.848              35 FALSE             TRUE                           0.00522            0.00189           0.00127
 5 linear              0.740              38 TRUE              FALSE                         30.3                0.0803            0.0102 
 6 logist~             0.795               3 TRUE              FALSE                          8.69               0.338             1.44   
 7 linear              0.661              49 FALSE             TRUE                          48.2               15.2               0.0771 
 8 logist~             0.630              17 FALSE             FALSE                          0.0175             0.00391          20.0    
 9 logist~             0.709              13 TRUE              TRUE                           1.23               6.49              0.139  
10 logist~             0.820              26 TRUE              FALSE                          0.171             86.9               5.33 

When running tune_grid the error that appears is

Error: The provided `grid` has the following parameter columns that have not been marked for tuning by `tune()`: 'linear'.
Run `rlang::last_error()` to see where the error occurred.
tonyk7440 commented 3 years ago

Hi @mdancho84, if you agree that the above is a bug then I would be willing to submit a pull request to fix, what do you think?

mdancho84 commented 3 years ago

Absolutely - Go for it.