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.07k stars 322 forks source link

Budget Allocator incorporating JSON file #910

Open DongHarry-Kang opened 5 months ago

DongHarry-Kang commented 5 months ago

Project Robyn

Describe issue

Describe your issue and provide warnings and error messages.

Provide reproducible example

Issues are often related to custom input data that is difficult to debug without. If necessary, please modify your data to mask real values and share a dataset that is able to reproduce the issue. Please also share your model configuration and exported JSON files if available.

Environment & Robyn version

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

Hi all - I used the below code to incorporate a previously created JSON file to recreate budget allocator pagers. However, I keep having the below error. could you let me know what when wrong?

Timing stopped at: 0.04 0.01 0.05 Error in { : task 1 failed - "Can't recycle channel_1_s (size 0) to match channel_2_s (size 99)."

gufengzhou commented 5 months ago

please clean up your message above bit more, as well as provide your code

DongHarry-Kang commented 5 months ago

Hi Gufeng -

Thank you very much for your strong support.

Here is the code: I need to mask some data as the information is confidential. In addition, I also noticed that it only happens when there are very many iterations (I tested 8000 iterations in 10 trials, 99 weekly data with 14 variables)

++ code ++ library(readxl) json_file = "~/Robyn_202401291646_init/RobynModel-7_539_10.json" dt_prophet_holidays <- read_excel("~/PJ Rodeo/Prophet_JP_Holidays.xlsx") -> file name masked simulation <- read_excel("~/test.xlsx") -> file name masked AllocatorCollect4 <- robyn_allocator( json_file = json_file, # Using json file from robyn_write() for allocation dt_input = simulation, dt_holidays = dt_prophet_holidays, date_range = c("2023-01-02","2023-11-20"), # Default last month as initial period total_budget = NULL, # When NULL, default is total spend in date_range channel_constr_low = c(1.0,0.5,1.0,0.5,0.5,0.5,0.5,0.5,1.0,0.5,0.5), channel_constr_up = c(1.0,1.5,1.0,1.5,1.5,1.5,1.5,1.5,1.0,1.5,1.5), scenario = "max_response", export = create_files

++ Error Message ++

Imported JSON file succesfully: ~/Robyn_202401291646_init/RobynModel-7_539_10.json

Running feature engineering... NOTE: potential improvement on splitting channels for better exposure fitting. Threshold (Minimum R2) = 0.8 Check: InputCollect$plotNLSCollect outputs Weak relationship for: "1_i", "2_i", "3_i", "4_i", "5_i", "6_i", "7_i", "8_i" and their spend Input data has 99 weeks in total: 2022-01-03 to 2023-11-20 Initial model is built on rolling window of 99 week: 2022-01-03 to 2023-11-20 Timing stopped at: 0.09 0.02 0.11 Error in { : task 1 failed - "Can't recycle 1_s (size 0) to match 2_s (size 99)." In addition: Warning messages: 1: In check_datadim(dt_input, all_ind_vars, rel = 10) : There are 14 independent variables & 99 data points. We recommend row:column ratio of 10 to 1 2: In summary.lm(modLM) : essentially perfect fit: summary may be unreliable 3: In check_datadim(dt_input, all_ind_vars, rel = 10) : There are 14 independent variables & 99 data points. We recommend row:column ratio of 10 to 1 4: In summary.lm(modLM) : essentially perfect fit: summary may be unreliable

caarolinagil commented 4 months ago

Have the same problem! Although I'm using robyn_recreate() to read the json from the model, but I've tried, but I have tried as you have done and I get the same error message.

I think that the problem is in the hyperparameters values when it's 0 but I'm confuse.

gufengzhou commented 4 months ago

I can't reproduce this error on simulated dataset. If you could share your json, dataframe and holiday files, I can try to debug