facebookexperimental / Robyn

Robyn is an experimental, AI/ML-powered and open sourced Marketing Mix Modeling (MMM) package from Meta Marketing Science. Our mission is to democratise modeling knowledge, inspire the industry through innovation, reduce human bias in the modeling process & build a strong open source marketing science community.
https://facebookexperimental.github.io/Robyn/
MIT License
1.15k stars 341 forks source link

Error in check_hyper_limits(hyperparameters_ordered, "thetas") #746

Closed jone735 closed 6 months ago

jone735 commented 1 year ago

Project Robyn

Describe issue

Im getting this error in R, when trying to set-up the Demo_Docker for use.

Error in check_hyper_limits(hyperparameters_ordered, "thetas") : print_S_thetas's hyperparameter must have upper bound <1

My Upper bound for the print_S_thetas hyperparameter is currently set to <1. Thanks for the help!

Provide reproducible example

library(Robyn) # remotes::install_github("facebookexperimental/Robyn/R") library(reticulate) library(remotes) set.seed(123)

Sys.setenv(R_FUTURE_FORK_ENABLE = "true") options(future.fork.enable = TRUE)

data("dt_simulated_weekly") head(dt_simulated_weekly)

data("dt_prophet_holidays") head(dt_prophet_holidays)

robyn_object <- "~/Desktop/MyRobyn.RDS"

plot_adstock(plot = T) plot_saturation(plot = T)

hyperparameters <- list( facebook_I_alphas = c(0.5, 3), facebook_I_gammas = c(0.3, 1), facebook_I_thetas = c(0, 0.3), print_S_alphas = c(0.5, 0.7), print_S_gammas = c(0.3, 0.4), print_S_thetas = c(0.1, 0.2), tv_S_alphas = c(0.5, 3), tv_S_gammas = c(0.3, 1), tv_S_thetas = c(0.3, 0.8), search_clicks_P_alphas = c(0.5, 3), search_clicks_P_gammas = c(0.3, 1), search_clicks_P_thetas = c(0, 0.3), ooh_S_alphas = c(0.5, 3), ooh_S_gammas = c(0.3, 1), ooh_S_thetas = c(0.1, 0.4), newsletter_alphas = c(0.5, 3), newsletter_gammas = c(0.3, 1), newsletter_thetas = c(0.1, 0.4), train_size = c(0.5, 0.8) )

InputCollect <- robyn_inputs( dt_input = dt_simulated_weekly, dt_holidays = dt_prophet_holidays, date_var = "DATE", dep_var = "revenue", dep_var_type = "revenue", prophet_vars = c("trend", "season", "holiday"), prophet_signs = c("default", "default", "default"), prophet_country = "DE", context_vars = c("competitor_sales_B", "events"), context_signs = c("default", "default"), paid_media_vars = c("tv_S", "ooh_S", "print_S", "facebook_I", "search_clicks_P"), paid_media_signs = c("positive", "positive", "positive", "positive", "positive"), paid_media_spends = c("tv_S", "ooh_S", "print_S", "facebook_S", "search_S"), organic_vars = "newsletter", organic_signs = "positive", factor_vars = "events", window_start = "2016-11-23", window_end = "2018-08-22", adstock = "geometric", iterations = 100, trials = 2, hyperparameters = hyperparameters )

hyper_names(adstock = InputCollect$adstock, all_media = InputCollect$all_media)

OutputCollect <- robyn_run( InputCollect = InputCollect, # feed in all model specification plot_folder = robyn_object, # plots will be saved in the same folder as robyn_object pareto_fronts = 1, plot_pareto = TRUE, )

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

gufengzhou commented 1 year ago

Hey, I realise you're using the .RDS file which is from a very old version. Please follow our latest demo.R without using the RDS in robyn_run and retry

onalivaiko commented 1 year ago

Hello! I'm getting exactly the same error without using .RDS

onalivaiko commented 1 year ago

@jone735 I figured it out. You need to base your paid media hyperparameters only on spend variables, not on impressions or other exposure variables. Here you need to switch to spend: facebook_I_alphas = c(0.5, 3), facebook_I_gammas = c(0.3, 1), facebook_I_thetas = c(0, 0.3), ... search_clicks_P_alphas = c(0.5, 3), search_clicks_P_gammas = c(0.3, 1), search_clicks_P_thetas = c(0, 0.3)

malaman5 commented 4 months ago

I am getting the same issue, the error I am getting is: "Error in check_hyper_limits(hyperparameters_ordered, "thetas") : pinterest_spend_thetas's hyperparameter must have upper bound <1". I used the Robyn version 3.10.3 and now with the 3.11.0, I got the same issue.

The hyperparameters are loaded via json: input_collect <- robyn_inputs( dt_holidays = dt_prophet_holidays, dt_input = dataset, json_file = parameters_file )

"pinterest_spend_alphas": [ 0.5, 3 ], "pinterest_spend_gammas": [ 0.3, 1 ], "pinterest_spend_thetas": [ 0.1, 0.4 ],

and "exposure_vars": [ "facebook_spend", "pinterest_spend", "tiktok_spend", "ext.GoogleTotalAd_spend" ], "paid_media_vars": [ "facebook_spend", "pinterest_spend", "tiktok_spend", "ext.GoogleTotalAd_spend" ], "mediaVarCount": 4, "all_media": [ "facebook_spend", "pinterest_spend", "ext.GoogleTotalAd_spend", "tiktok_spend" ], "paid_media_spends": [ "facebook_spend", "pinterest_spend", "ext.GoogleTotalAd_spend", "tiktok_spend" ],

The details of the session: R version 4.3.2 (2023-10-31) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 22.04.3 LTS attached base packages: [1] stats graphics grDevices datasets utils methods base

other attached packages: [1] jsonlite_1.8.7 Robyn_3.11.0

loaded via a namespace (and not attached): [1] tidyr_1.3.0 utf8_1.2.3 generics_0.1.3 renv_1.0.3 prophet_1.0
[6] xml2_1.3.5 bitops_1.0-7 h2o_3.42.0.2 shape_1.4.6 stringi_1.7.12
[11] lattice_0.22-5 digest_0.6.33 magrittr_2.0.3 pROC_1.18.4 grid_4.3.2
[16] timechange_0.2.0 iterators_1.0.14 foreach_1.5.2 doParallel_1.0.17 plyr_1.8.9
[21] glmnet_4.1-8 Matrix_1.6-3 zip_2.3.0 survival_3.5-7 httr_1.4.7
[26] rvest_1.0.3 rpart.plot_3.1.1 purrr_1.0.2 fansi_1.0.4 doRNG_1.8.6
[31] scales_1.2.1 codetools_0.2-19 cli_3.6.1 rlang_1.1.1 munsell_0.5.0
[36] splines_4.3.2 withr_2.5.1 yaml_2.3.7 tools_4.3.2 parallel_4.3.2
[41] nloptr_2.0.3 minpack.lm_1.2-4 dplyr_1.1.3 colorspace_2.1-0 ggplot2_3.4.3
[46] rngtools_1.5.2 reticulate_1.32.0 png_0.1-8 vctrs_0.6.3 lares_5.2.2
[51] R6_2.5.1 rpart_4.1.23 ggridges_0.5.4 lifecycle_1.0.3 lubridate_1.9.3
[56] stringr_1.5.0 pkgconfig_2.0.3 RcppParallel_5.1.7 pillar_1.9.0 openxlsx_4.2.5.2
[61] gtable_0.3.4 glue_1.6.2 Rcpp_1.0.11 tibble_3.2.1 tidyselect_1.2.0
[66] patchwork_1.1.3 compiler_4.3.2 RCurl_1.98-1.12