-
Notifications
You must be signed in to change notification settings - Fork 351
Open
Labels
Description
I was trying to run the example notebook from #1521 with
model_config = {
"intercept": Prior("Normal", mu=0.5, sigma=0.2, dims="geo"),
"gamma_control": Prior("Normal", mu=0, sigma=0.03, dims="control"),
"gamma_fourier": Prior("Laplace", mu=0, b=0.2, dims=("geo", "fourier_mode")),
'intercept_tvp_config': HSGPKwargs(m=200, L=None, eta_lam=1, ls_mu=5, ls_sigma=5),
"likelihood": Prior(
"TruncatedNormal",
lower=0,
sigma=Prior("HalfNormal", sigma=Prior("HalfNormal", sigma=1)),
dims=("date", "geo"),
),
}and I get the error at build time
File ~/Documents/pymc-marketing/pymc_marketing/mmm/multidimensional.py:1109, in MMM.build_model(self, X, y, **kwargs)
[1104](https://file+.vscode-resource.vscode-cdn.net/Users/juanitorduz/Documents/pymc-marketing/docs/source/notebooks/mmm/~/Documents/pymc-marketing/pymc_marketing/mmm/multidimensional.py:1104) if self.time_varying_intercept:
[1105](https://file+.vscode-resource.vscode-cdn.net/Users/juanitorduz/Documents/pymc-marketing/docs/source/notebooks/mmm/~/Documents/pymc-marketing/pymc_marketing/mmm/multidimensional.py:1105) baseline_intercept = self.model_config["intercept"].create_variable(
[1106](https://file+.vscode-resource.vscode-cdn.net/Users/juanitorduz/Documents/pymc-marketing/docs/source/notebooks/mmm/~/Documents/pymc-marketing/pymc_marketing/mmm/multidimensional.py:1106) "baseline_intercept"
[1107](https://file+.vscode-resource.vscode-cdn.net/Users/juanitorduz/Documents/pymc-marketing/docs/source/notebooks/mmm/~/Documents/pymc-marketing/pymc_marketing/mmm/multidimensional.py:1107) )
-> [1109](https://file+.vscode-resource.vscode-cdn.net/Users/juanitorduz/Documents/pymc-marketing/docs/source/notebooks/mmm/~/Documents/pymc-marketing/pymc_marketing/mmm/multidimensional.py:1109) intercept_latent_process = SoftPlusHSGP.parameterize_from_data(
[1110](https://file+.vscode-resource.vscode-cdn.net/Users/juanitorduz/Documents/pymc-marketing/docs/source/notebooks/mmm/~/Documents/pymc-marketing/pymc_marketing/mmm/multidimensional.py:1110) X=time_index, # this is
[1111](https://file+.vscode-resource.vscode-cdn.net/Users/juanitorduz/Documents/pymc-marketing/docs/source/notebooks/mmm/~/Documents/pymc-marketing/pymc_marketing/mmm/multidimensional.py:1111) dims=("date", *self.dims),
[1112](https://file+.vscode-resource.vscode-cdn.net/Users/juanitorduz/Documents/pymc-marketing/docs/source/notebooks/mmm/~/Documents/pymc-marketing/pymc_marketing/mmm/multidimensional.py:1112) **self.model_config["intercept_tvp_config"],
[1113](https://file+.vscode-resource.vscode-cdn.net/Users/juanitorduz/Documents/pymc-marketing/docs/source/notebooks/mmm/~/Documents/pymc-marketing/pymc_marketing/mmm/multidimensional.py:1113) ).create_variable("intercept_latent_process")
[1115](https://file+.vscode-resource.vscode-cdn.net/Users/juanitorduz/Documents/pymc-marketing/docs/source/notebooks/mmm/~/Documents/pymc-marketing/pymc_marketing/mmm/multidimensional.py:1115) intercept = pm.Deterministic(
[1116](https://file+.vscode-resource.vscode-cdn.net/Users/juanitorduz/Documents/pymc-marketing/docs/source/notebooks/mmm/~/Documents/pymc-marketing/pymc_marketing/mmm/multidimensional.py:1116) name="intercept_contribution",
[1117](https://file+.vscode-resource.vscode-cdn.net/Users/juanitorduz/Documents/pymc-marketing/docs/source/notebooks/mmm/~/Documents/pymc-marketing/pymc_marketing/mmm/multidimensional.py:1117) var=baseline_intercept[None, ...] * intercept_latent_process,
[1118](https://file+.vscode-resource.vscode-cdn.net/Users/juanitorduz/Documents/pymc-marketing/docs/source/notebooks/mmm/~/Documents/pymc-marketing/pymc_marketing/mmm/multidimensional.py:1118) dims=("date", *self.dims),
[1119](https://file+.vscode-resource.vscode-cdn.net/Users/juanitorduz/Documents/pymc-marketing/docs/source/notebooks/mmm/~/Documents/pymc-marketing/pymc_marketing/mmm/multidimensional.py:1119) )
[1120](https://file+.vscode-resource.vscode-cdn.net/Users/juanitorduz/Documents/pymc-marketing/docs/source/notebooks/mmm/~/Documents/pymc-marketing/pymc_marketing/mmm/multidimensional.py:1120) else:
TypeError: pymc_marketing.mmm.hsgp.HSGP.parameterize_from_data() argument after ** must be a mapping, not HSGPKwargsI think the issue is we are not not expecting HSGPKwargs anywhere as the default config has 'intercept_tvp_config': {'ls_lower': 0.3, 'ls_upper': 2.0},, which is passed to
pymc-marketing/pymc_marketing/mmm/multidimensional.py
Lines 1109 to 1113 in 06d1a34
| intercept_latent_process = SoftPlusHSGP.parameterize_from_data( | |
| X=time_index, # this is | |
| dims=("date", *self.dims), | |
| **self.model_config["intercept_tvp_config"], | |
| ).create_variable("intercept_latent_process") |
However, we are parsing the model_config at the init stage:
pymc-marketing/pymc_marketing/mmm/multidimensional.py
Lines 297 to 300 in 06d1a34
| model_config = parse_model_config( | |
| model_config, # type: ignore | |
| hsgp_kwargs_fields=["intercept_tvp_config", "media_tvp_config"], | |
| ) |