Skip to content

Commit

Permalink
Prior predictive guide (#1334)
Browse files Browse the repository at this point in the history
* raw text guiding Claude

* init nb

* simple case init

* first iteration simple example

* add docs

* mmm init

* pre-commit

* allow prior_predictive

* mmm prior analysis

* mmm example code

* error

* intro mmm

* mmm text

* tv itercept priors

* prior intercept

* first final iteration

* rm file

* ab testing reference

* feedback part 1

* feedback p2

* stan link

* rm ugly cell output
  • Loading branch information
juanitorduz authored Jan 10, 2025
1 parent 7dfa955 commit 38e7e00
Show file tree
Hide file tree
Showing 3 changed files with 2,081 additions and 2 deletions.
2,070 changes: 2,070 additions & 0 deletions docs/source/notebooks/general/prior_predictive.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/source/notebooks/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ customer_choice/mv_its_unsaturated

general/model_configuration
general/other_nuts_samplers
general/prior_predictive
:::
12 changes: 10 additions & 2 deletions pymc_marketing/mmm/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -910,16 +910,24 @@ def plot_components_contributions(self, **plt_kwargs: Any) -> plt.Figure:
)
return fig

def compute_channel_contribution_original_scale(self) -> DataArray:
def compute_channel_contribution_original_scale(
self, prior: bool = False
) -> DataArray:
"""Compute the channel contributions in the original scale of the target variable.
Parameters
----------
prior : bool, optional
Whether to use the prior or posterior, by default False (posterior)
Returns
-------
DataArray
"""
_data = self.prior if prior else self.fit_result
channel_contribution = az.extract(
data=self.fit_result, var_names=["channel_contributions"], combined=False
data=_data, var_names=["channel_contributions"], combined=False
)

# sklearn preprocessers expect 2-D arrays of (obs, features)
Expand Down

0 comments on commit 38e7e00

Please sign in to comment.