google / lightweight_mmm

LightweightMMM 🦇 is a lightweight Bayesian Marketing Mix Modeling (MMM) library that allows users to easily train MMMs and obtain channel attribution information.
https://lightweight-mmm.readthedocs.io/en/latest/index.html
Apache License 2.0
850 stars 175 forks source link

IndexError when using plot_prior_and_posterior, with fit(..., weekday_seasonality = True) #171

Open lloydvissers opened 1 year ago

lloydvissers commented 1 year ago

Hello,

I'm trying to plot the prior and posterior distributions of my model's parameters.

When do mmm.fit(..., weekday_seasonality = False), the function mmm.plot_prior_and_posterior(...) plots are returned. When do mmm.fit(..., weekday_seasonality = True), the function mmm.plot_prior_and_posterior(...) Gives an index error. The function plots all parameters, except for the 7-weekday parameters.

IndexError: Too many indices for array: 3 non-None/Ellipsis indices for dim 2. index_error

Am I doing something wrong? Is this a known issue? What more information do you need to examine the issue?

Thanks in advance!

steven-struglia commented 1 year ago

Are you using a geo-model or just a national model (dim 3 or dim 2 media data)?

I'm wondering what mmm.print_summary() looks like for your model, specifically what the weekday seasonality parameters come out like.

lloydvissers commented 1 year ago

Using national model, I did 500x samples & warmup. summary is attached. image image

I can not send you the data and code since it is confidential.

However, approximately the same thing happens when running the demo codes available: "end_to_end_demo_with_multiple_geos.ipynb" & "simple_end_to_end_demo.ipynb". when running the end_to_end_demo, with: !pip install --upgrade git+https://github.com/google/lightweight_mmm.git !pip install numpy==1.20.3

image AttributeError: 'Figure' object has no attribute '_get_renderer'

steven-struglia commented 1 year ago

@lloydvissers I worry about your model results -- it seems very very poor. Have you plotted the model fit on in-sample data, or does that function also not work? Your r_hat's are insane: they should all be ~1-1.05 ideally, not in the thousands.

lloydvissers commented 1 year ago

@steven-struglia i'm debugging serval issues, so my code is a bit of a mess. I've new results, maybe some data import was wrong but now the results are better. But the "AttributeError: 'Figure' object has no attribute '_get_renderer'" remains

image