Skip to content

Commit 0d0464d

Browse files
committed
Add possibility to create original scale vars
1 parent 5b59de5 commit 0d0464d

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
schema_version: 1
2+
3+
# ----------------------------------------------------------------------
4+
model:
5+
target: pymc_marketing.mmm.multidimensional.MMM
6+
kwargs:
7+
date_column: "date"
8+
channel_columns: # explicit for reproducibility
9+
- channel_1
10+
- channel_2
11+
#
12+
target_column: "kpi_registrations"
13+
14+
# --- media transformations ---------------------------------------
15+
adstock:
16+
target: pymc_marketing.mmm.GeometricAdstock
17+
kwargs: {l_max: 12} # any other hyper-parameters here
18+
19+
saturation:
20+
target: pymc_marketing.mmm.MichaelisMentenSaturation
21+
kwargs: {} # default α, λ priors inside the class
22+
23+
# ----------------------------------------------------------------------
24+
# (optional) sampler options you plan to forward to pm.sample():
25+
sample_kwargs:
26+
tune: 1000
27+
draws: 200
28+
chains: 8
29+
random_seed: 42
30+
target_accept: 0.90
31+
nuts_sampler: "numpyro"
32+
33+
# ----------------------------------------------------------------------
34+
# (optional) idata from a previous sample
35+
# idata_path: "data/idata.nc"
36+
37+
# ----------------------------------------------------------------------
38+
# (optional) Data paths
39+
# data:
40+
# X_path: "data/X.csv"
41+
# y_path: "data/y.csv"
42+
43+
# ----------------------------------------------------------------------
44+
# (optional) Add original scale contribution variables
45+
# These will be processed after model building but before attaching idata
46+
original_scale_vars:
47+
- channel_contribution
48+
- intercept_contribution

pymc_marketing/mmm/builders/yaml.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,12 @@ def build_from_yaml(
9393
# 4 ───────────────────────────────────────────── build PyMC graph
9494
model.build_model(X, y) # this **must** precede any idata loading
9595

96-
# 5 ──────────────────────────────────────────── attach inference data
96+
# 5 ───────────────────────── add original scale contribution variables
97+
original_scale_vars = cfg.get("original_scale_vars", [])
98+
if original_scale_vars:
99+
model.add_original_scale_contribution_variable(var=original_scale_vars)
100+
101+
# 6 ──────────────────────────────────────────── attach inference data
97102
if (idata_fp := cfg.get("idata_path")) is not None:
98103
idata_path = Path(idata_fp)
99104
if os.path.exists(idata_path):

0 commit comments

Comments
 (0)