Skip to content

Commit

Permalink
scaling should be done before hdi computation (#970)
Browse files Browse the repository at this point in the history
  • Loading branch information
juanitorduz authored and twiecki committed Sep 10, 2024
1 parent dc4296c commit 557b9a9
Showing 1 changed file with 7 additions and 5 deletions.
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 @@ def plot_posterior_predictive(
else:
fig = ax.figure

if original_scale:
posterior_predictive_data = apply_sklearn_transformer_across_dim(
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

0 comments on commit 557b9a9

Please sign in to comment.