Skip to content

Commit e78e3af

Browse files
cetagostinijuanitorduzdrbenvincent
authored
Refactor and enhance SensitivityAnalysis for MMM (#1899)
* Refactor and enhance SensitivityAnalysis for MMM Expanded SensitivityAnalysis to support arbitrary PyMC models, improved documentation with usage examples, and added flexible sweep and filtering logic. The class now works directly with PyMC models and InferenceData, supports multi-dimensional inputs, and provides Jacobian-based marginal effects with optional xarray output and idata extension. Legacy code using pandas was removed in favor of a more general and robust approach. * changes * Applying Erik feedback * Refactor MMM sensitivity analysis and update tests Updated sensitivity analysis logic in pymc_marketing/mmm/sensitivity_analysis.py and related plotting in plot.py. Adjusted notebook outputs and execution counts for reproducibility. Modified tests to align with new sensitivity analysis behavior. * Update * Changes * Feedback from team * Changes requested by Ben * Avoid the use of nutpie * Remove warning --------- Co-authored-by: Juan Orduz <[email protected]> Co-authored-by: Benjamin T. Vincent <[email protected]>
1 parent bc2d045 commit e78e3af

File tree

6 files changed

+4109
-6940
lines changed

6 files changed

+4109
-6940
lines changed

docs/source/notebooks/mmm/mmm_sensitivity_analysis.ipynb

Lines changed: 2743 additions & 6061 deletions
Large diffs are not rendered by default.

pymc_marketing/mmm/multidimensional.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1713,7 +1713,10 @@ def sensitivity(self) -> SensitivityAnalysis:
17131713
... sweep_type="multiplicative",
17141714
... )
17151715
"""
1716-
return SensitivityAnalysis(mmm=self)
1716+
# Provide the underlying PyMC model, the model's inference data, and dims
1717+
return SensitivityAnalysis(
1718+
pymc_model=self.model, idata=self.idata, dims=self.dims
1719+
)
17171720

17181721
def _make_channel_transform(
17191722
self, df_lift_test: pd.DataFrame

0 commit comments

Comments
 (0)