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

Cannot plot model onepager with ts_validation = False with "non-numeric argument to mathematical function" error #946

Closed rupatrawut closed 1 month ago

rupatrawut commented 3 months ago

Project Robyn

Describe issue

If I train Robyn model with ts_validation set to False, everything looks fine in training phrase. I got all the output such as pareto_aggregated.csv, etc without problem.

However, when calling robyn_outputs api via plumber, I got error message in robyn_log file as below:

Plotting 20 selected models on 7 cores... |
| | 0%Failed exporting results, but returned model results anyways: Error in {: task 1 failed - "non-numeric argument to mathematical function"

I also try this function but return following error.

#write one pager to specified location
load_onepager(sol='1_5_1', write=True, InputJson=InputCollect, OutputJson=OutputCollect, path=output_folder)

----> 4 load_onepager(sol='1_5_1', write=True, InputJson=InputCollect, OutputJson=OutputCollect, path=output_folder)

File c:\Users\rupatrawut\workspace\ml-marketing-mix-modeling\ml_mmm_robyn\robyn_api\python_helper.py:263, in load_onepager(InputJson, OutputJson, path, sol, top_pareto, write, max_size) 261 sol_id = sol 262 onepager = load_modeldata(sol_id,InputJson=InputJson,OutputJson=OutputJson) --> 263 image_data = binascii.unhexlify("".join(onepager)) 264 if(write==True): 265 writefile(datset=image_data,path=path,sol_id=sol_id)

Error: Odd-length string

Please note that the code can be ran without any issues, when ts_validation = True.

Environment & Robyn version

Robyn version: '3.10.5.9014' R version: 4.3.2

Thank you for your support :)

yu-ya-tanaka commented 2 months ago

Hi, I reproduced the same error on my env with setting ts_validation = False. Will check later and get back to you.

rupatrawut commented 2 months ago

@yu-ya-tanaka Thank you :) Please keep me posted.

Another question, once we get the best range of hyperparameter when running ts_val = TRUE, should we train 100% of data using ts_val = FALSE? And insights presented in onepager (e.g., ROI, effect share, decomposition impact) are calculated from training period only or total data point?

gufengzhou commented 2 months ago

For most usecases, I'd recommend to ts_validation = FALSE. Most onepager numbers are based on the entire modeling window. The training/val/test split is only for time series validation purpose. I'll let Yuya to help you with the bug.

yu-ya-tanaka commented 2 months ago

Hi @rupatrawut , I have found the cause, there is a problem with the API endpoint and we are fixing it now. The fix will be completed by the end of next week.

rupatrawut commented 2 months ago

Hi @yu-ya-tanaka. Noted with thanks :)

yu-ya-tanaka commented 1 month ago

Hi @rupatrawut , We fixed bug in the API endpoint file and merged updates to the main branch. Please use the latest version of endpoint file. Thanks, https://github.com/facebookexperimental/Robyn/tree/main/robyn_api

rupatrawut commented 1 month ago

Hi @yu-ya-tanaka Many thanks :)