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

robyn_refresh assumes default model path #649

Closed
rocker-david opened this issue Mar 10, 2023 · 1 comment · Fixed by #708
Closed

robyn_refresh assumes default model path #649

rocker-david opened this issue Mar 10, 2023 · 1 comment · Fixed by #708
Assignees

Comments

@rocker-david
Copy link

Project Robyn

Describe issue

When I save trained model to a non-default path, I get the following behaviors:

  robyn_write(
    InputCollect,
    OutputCollect,
    select_model = sol_id,
    dir = paste(OutputCollect$plot_folder,"models",sep = "")
  )

Using a custom path (e.g. outputs/Robyn_202303101230_init/models/RobynModel-2_16_5.json) I can load it back no problem.

pretrained_model_json_file <- "outputs/Robyn_202303101230_init/models/RobynModel-2_16_5.json"
json_obj <- robyn_read(pretrained_model_json_file)
>>> Recreating model 2_16_5
Imported JSON file succesfully: outputs/Robyn_202303101230_init/models/RobynModel-2_16_5.json

then I run robyn_refresh

RobynRefresh <- robyn_refresh(
  json_file = pretrained_model_json_file,
  dt_input = refresh_df,
  dt_holidays = custom_holidays,
  refresh_steps = 30,
  refresh_iters = 200,
  refresh_trials = 5,
  ts_validation = TRUE,
  plot_folder = robyn_output_dir
)
>> Running feature engineering...
Input data has 730 days in total: 2019-01-01 to 2020-12-30
Initial model is built on rolling window of 700 day: 2019-01-01 to 2020-11-30
Successfully recreated model ID: 2_16_5
Error in difftime(totalDates, refreshStart, units = "days") : 
  object 'refreshStart' not found

I'm able to get around this by adding

refreshStart <- '2019-01-01'
refreshEnd <- '2020-12-30'

now it successfully runs and saves outputs
but breaks before returning the RobynRefresh object successfullly with the following message

...
>> Exported model inputs as ./outputs/Robyn_202303101230_init/Robyn_202303101355_rf1/RobynModel-inputs.json
- DECOMP.RSSD NOT converged: sd@qt.20 0.13 > 0.036 & |med@qt.20| 0.037 > 0.014
- NRMSE NOT converged: sd@qt.20 0.21 > 0.063 & |med@qt.20| 1.4 > 1.4
Total run time: 1.3 mins
Selected model ID: 1_10_8 for refresh model #1 based on the smallest combined normalised errors
Error in robyn_read(filename, quiet = TRUE) : 
  JSON file can't be imported: ./outputs/Robyn_202303101230_init/RobynModel-2_16_5.json

I noticed I'm saving to the regular output path, with an added models folder nested, but this exception assumes the filename to be in the default path:

  • outputs/Robyn_202303101230_init/models/RobynModel-2_16_5.json
  • outputs/Robyn_202303101230_init/RobynModel-2_16_5.json

I think the error may be happening as it assumes the filename and passes to robyn_read

I've been able to get around and successfully run the function by saving the model file to the assumed path.
I don't know if this is an actual bug or if we're not supposed to save / load the models anywhere else other than the default path but was hoping to see if we can just pass the json_file path directly to robyn_read

Provide reproducible example

I'm using dummy daily sample data I can provide if requested, but I think this should be reproduce-able with the code provided above as I reproduced it with both sample data and real data.

Environment & Robyn version

Make sure you're using the latest Robyn version before you post an issue.

  • Check and share Robyn version: packageVersion("Robyn")
    • 3.9.0
  • R version (Please, check and share: sessionInfo() or R.version$version.string)
    • 4.2.1

Thanks in advance and big kudos/thanks to the Robyn team!

@rocker-david rocker-david changed the title robyn_refresh says refreshDepth not found robyn_refresh assumes default model path Mar 10, 2023
@rocker-david
Copy link
Author

rocker-david commented Mar 13, 2023

having the model saved to the assumed path (without the models subdir) works

richin13 added a commit to richin13/Robyn that referenced this issue Apr 25, 2023
laresbernardo pushed a commit that referenced this issue Apr 25, 2023
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

Successfully merging a pull request may close this issue.

2 participants