Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scaling should be done before hdi computation posterior predictive #970

Merged
merged 2 commits into from
Aug 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions pymc_marketing/mmm/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,16 +404,18 @@
else:
fig = ax.figure

if original_scale:
posterior_predictive_data = apply_sklearn_transformer_across_dim(

Check warning on line 408 in pymc_marketing/mmm/base.py

View check run for this annotation

Codecov / codecov/patch

pymc_marketing/mmm/base.py#L407-L408

Added lines #L407 - L408 were not covered by tests
data=posterior_predictive_data,
func=self.get_target_transformer().inverse_transform,
dim_name="date",
)

for hdi_prob, alpha in zip((0.94, 0.50), (0.2, 0.4), strict=True):
likelihood_hdi: DataArray = az.hdi(
ary=posterior_predictive_data, hdi_prob=hdi_prob
)[self.output_var]

if original_scale:
likelihood_hdi = self.get_target_transformer().inverse_transform(
likelihood_hdi
)

ax.fill_between(
x=posterior_predictive_data.date,
y1=likelihood_hdi[:, 0],
Expand Down
Loading