Open louismagowan opened 3 months ago
Hey @louismagowan,
You could use this alternative to get those channel contributions over time if you pass more model variables to var_names
.
I'll let the dev team answer why it's limited to self.fit_result
and extend_idata=True
is not used in any of the examples for out-of-sample.
y_test_pred = mmm.sample_posterior_predictive(
X_pred=X_test,
extend_idata=False,
include_last_observations=True,
var_names=["y", "channel_contributions"],
original_scale=False
)
mean_contributions_by_channel = (
y_test_pred['channel_contributions']
.mean(dim='sample')
.values
* mmm.get_target_transformer()["scaler"].scale_ # rescale contribution
)
Note that I'm using 0.7.0
and set the original_scale=False
because I got this error when original_scale=True
:
ValueError: Found array with dim 3. None expected <= 2.
So you would need to rescale the predictions
Thanks @AlfredoJF ! I'm gonna test out your solution now π
I encountered the same error when using original_scale=True
, so thanks for the explanation and tips!
Hi there,
I've attached some code and screenshots below which should hopefully illustrate my point. Essentially, I'm building my MMM with some training data and then testing it's predictions with some test data. However, I would like to get channel contributions not just for my training data (which is in the idata), but also for my test data and the full dataset (train + test).
I would appreciate any advice or tips you have π
TL;DR
predict
,predict_posterior
andsample_posterior_predictive
can extend idata for predictions of my target