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.16k stars 347 forks source link

robyn_refresh "Error: ValueError: zero-size array to reduction operation minimum which has no identity" #761

Closed ChrisHaferl closed 7 months ago

ChrisHaferl commented 1 year ago

Project Robyn

Describe issue

On robyn_refresh I am getting an error of "Error: ValueError: zero-size array to reduction operation minimum which has no identity"

Provide reproducible example

library(Robyn) #Using Robyn_3.10.3
#Load data used to build model + new data
dt_input_data <- read.csv(file = '~/Documents/data-scratch/chrishaferl/MMMv2/USA_Model/Robyn_202306140111_init/raw_data.csv')
#Load saved model, located in model output folder
json_file <- "~/Documents/data-scratch/chrishaferl/MMMv2/USA_Model/Robyn_202306140111_init/RobynModel-6_95_13.json"
RobynRefresh <- robyn_refresh(
  json_file = json_file,
  dt_input = dt_input_data,
  dt_holidays = dt_prophet_holidays,
  refresh_steps = 12, #Number of weeks to add
  refresh_iters = 1000, # 1k is an estimation
  refresh_trials = 1
)

Output:

>>> Recreating model 6_95_13
Imported JSON file succesfully: ~/Documents/data-scratch/chrishaferl/MMMv2/USA_Model/Robyn_202306140111_init/RobynModel-6_95_13.json
>> Running feature engineering...
Input data has 178 weeks in total: 2020-01-06 to 2023-05-29
Initial model is built on rolling window of 84 week: 2021-05-31 to 2023-01-02
>>> Calculating response curves for all models' media variables (9)...
Successfully recreated model ID: 6_95_13

>>> Building refresh model #1 in manual mode
>>> New bounds freedom: 14.29%
>> Running feature engineering...
Input data has 178 weeks in total: 2020-01-06 to 2023-05-29
Refresh #1 model is built on rolling window of 84 week: 2021-08-23 to 2023-03-27
Rolling window moving forward: 12 weeks
Warning: Provided train_size but ts_validation = FALSE. Time series validation inactive.Fitting time series with all available data...
Using weibull_pdf adstocking with 46 hyperparameters (0 to iterate + 46 fixed) on 15 cores
>>> Starting 1 trials with 1000 iterations each using TwoPointsDE nevergrad algorithm...
  Running trial 1 of 1
Error: ValueError: zero-size array to reduction operation minimum which has no identity

Environment & Robyn version

Using Robyn_3.10.3

gufengzhou commented 1 year ago

Hi, I can't reproduce your error. I tested it with both geometric and weibull using the simulated data through the 1st refresh and everything works. I noticed that your prompt says :

Using weibull_pdf adstocking with 46 hyperparameters (0 to iterate + 46 fixed) on 15 cores

This shouldn't be the case though, it shouldn't be all fixed. because otherwise there's no need to model if all hyperparameters are known. I can't think of a reason though. Can you share your json file?

ChrisHaferl commented 1 year ago

@gufengzhou Right, that is odd, attached the model JSON (had to save as txt as json upload not supported here)

RobynModel-6_95_13.txt

rsplima commented 1 year ago

Any news on this? I also get this exact error message when running robyn_refresh (I've tried editing my JSON file and setting hyper_fixed = 'false', without success).

tiagoyuhang commented 9 months ago

I am getting the same problem. One of the things I have noticed is that the "hyper_updated" has single values (as in the hyper_values) in all the json model config files that were shared with this problem, instead of a range of values.

When I ran the demo.R example, I've noticed that the model json output "hyper_updated" had a range of values. eg: "facebook_S_alphas": [0.5, 3];

I tried to manually change one of the "single values" in my specific failing case to a range of values in "hyper_updated" (eg. from "facebook_S_alphas": [2.9709] to "facebook_S_alphas": [0.5, 3]) and then I was able to run robyn_refresh.

gufengzhou commented 7 months ago

Interesting finding. I've just tested changing one or two "hyper_updated" ranges into single values and the refresh still runs though. I'm on the latest version. Please reopen if issue reoccurs