Can I get channel contribution inference from out of sample prediction

Hi there!

I am following the MMM notebook example for DelayedSaturatedMMM… I have finished the model development and fitted an out of sample predictions… My question is, from the out of samples prediction, how can i extract the contribution by each channel based on this new out-of-sample spend?

Using the example notebook, the out of sample prediction outputted the total estimated “sales” with this new spend
dollar… How can i break it down, from the 6 new sales, how much are from Channel X1 vs X2?

Thanks in advanced!

I have the same problem. Does anyone have a solution?

I think you can adapt the code of the notebook to sample from the channel contributions as

y_out_of_sample = mmm.sample_posterior_predictive(
    X_pred=X_out_of_sample,
    extend_idata=False,
    var_names=["y", "channel_contributions"],
)

Let me know if this works for you :slight_smile:

1 Like

Unfortunately no…

Can you please explain why not please? I need more info to help you :wink:

1 Like

There are only y values in the result. I need something similar to mmm.compute_mean_contributions_over_time() - here I can obtain contribution of each channel, yearly seasonality and intercept, but it works for the train data.

ok! I was able to bring the out-of-sample contributions in a case study I am writing MMM Case Study from PyData Global by juanitorduz · Pull Request #1044 · pymc-labs/pymc-marketing · GitHub . This is the code from the main branch. I think this should work on the latest release version as well.

1 Like

thanks so much @juanitorduz ! is this only working on pymc 0.9.0? i tried it on 0.8.0 and it’s showing that “channel_contributions” isn’t available…

Very possibly.