facebookexperimental / facebookexperimental/Robyn

Discrepancies in variable parameters during Robyn model recreation

Open
#1,312 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
1.5k
Forks
433
PR merge metrics
No merged PRs in 30d

Description

Hi Robyn team,

I am attempting to recreate a model that I previously saved using `robyn_write`, but I'm encountering an issue where the variable parameters don’t match the original ones. Both the saving and recreating processes are executed in the same environment with Robyn package version 3.11.1. Below are the code snippets I used:

### Save Model
```r
ExportedModel <- robyn_write(InputCollect, OutputCollect, select_model, export = TRUE)
print(ExportedModel)
```

### Recreate Model
```r
# Read original JSON
original_json <- robyn_read(json_file, quiet = TRUE)

# Recreate model
recreated_result <- robyn_recreate(json_file)

# Compare key coefficients
original_coefs <- original_json$ExportedModel$summary$coef
recreated_coefs <- recreated_result$OutputCollect$DecompAggs$coef

# Check differences
max_diff <- max(abs(original_coefs - recreated_coefs), na.rm = TRUE)
cat("Maximum coefficient difference: ", max_diff, "\n")

if (max_diff < 1e-10) {
cat("✅ Recreation successful! Coefficients are identical.\n")
} else {
cat("❌ Recreation failed. There are differences in coefficients.\n")
}
```

When recreating, the output shows:
```
>>> Recreating 3_382_3

Imported JSON file successfully: /mnt/workspace/AprilSun/MMM /output/tmall_brand_zone/Robyn_202510171133_init/RobynModel-3_382_3.json

>> Running feature engineering...

Warning message in prophet_decomp(dt_transform, dt_holidays = InputCollect$dt_holidays, :
“Currently, there's a known issue with prophet that may crash this use case.
Read more here: [https://github.com/facebookexperimental/Robyn/issues/472”](https://github.com/facebookexperimental/Robyn/issues/472%E2%80%9D)
Input data has 1096 days in total: 2022-09-01 to 2025-08-31

Initial model is built on rolling window of 1096 day: 2022-09-01 to 2025-08-31

>>> Calculating response curves for all models' media variables (3)...

Successfully recreated model ID: 3_382_3

最大系数差异: 63537.45
❌ 重现失败,系数存在差异
```

I would appreciate any guidance on why the variable parameters aren’t matching and how to resolve this discrepancy. Thank you!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.