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 when running pareto calculations #1099

Open malaman5 opened 6 days ago

malaman5 commented 6 days ago

Project Robyn

Describe issue

When running a model using a calibration, Robyn throws an error when running the pareto computations:

>>> Running Pareto calculations for 10000 models on 3 fronts.. Error inmutate(): ℹ In argument:mape_n = .min_max_norm(.data$mape). Caused by error: !mape_nmust be size 10000 or 1, not 22.

Provide reproducible example

The parameters file used are attached: parameters.json dataset.csv

Environment & Robyn version

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

laresbernardo commented 6 days ago

Hi @malaman5

For reproducibility, I'm sharing the code I've tested and I don't encounter the error.

json_file <- ".../parameters.json"
dt_input_csv <- ".../dataset.csv"
json_data <- robyn_read(json_file)
dt_input <- read.csv(dt_input_csv)

InputCollect <- robyn_inputs(
  dt_input = dt_input, 
  json_file = json_file)
OutputModels  <- robyn_run(
  InputCollect = InputCollect,
  iterations = 1000,
  trials = 1)
OutputCollect <- robyn_outputs(
  InputCollect, OutputModels,
  pareto_fronts = 2, 
  export = FALSE)

Can you please check what's the difference between your code and the reproducible example? If you run this example do you get the error? I'm currently on version 3.11.1.9004 but there hasn't been any changes on the calibration code for a while. Feel free to reach back.

For reference, this is where the code is triggering your error.

malaman5 commented 6 days ago

When running with the provided code, at first attempt I got the following error: Error in fix.by(by.y, y) : 'by' must specify uniquely valid columns

I increased the number of iterations to 2000 and the error was as follows, and looks to be related to the mutate function, but most likely because it didn't converge: `Couldn't automatically create clusters: Error in sample.int(m, k): cannot take a sample larger than the population when 'replace = FALSE'

Error in UseMethod("mutate") : no applicable method for 'mutate' applied to an object of class "NULL"`