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

Skip coords with scalar values #839

Closed
wd60622 opened this issue Jul 17, 2024 · 0 comments · Fixed by #868
Closed

Skip coords with scalar values #839

wd60622 opened this issue Jul 17, 2024 · 0 comments · Fixed by #868
Labels
good first issue Good for newcomers MMM

Comments

@wd60622
Copy link
Contributor

wd60622 commented Jul 17, 2024

The plot_curve which power the media and fourier plotting functionality will fail while having scalar values in the coordinates.

This can be solved by using reset_coords method on the Dataset. However, this can be done internally

Setup:

from pymc_marketing.prior import Prior
from pymc_marketing.mmm import YearlyFourier

fourier = YearlyFourier(
    n_order=3,
    prior=Prior(
        "Laplace", 
        mu=0,
        b=Prior(
            "Gamma", 
            mu=1, 
            sigma=1, 
            dims=("geo", "fourier"),
        ), 
        dims=("geo", "fourier"), 
    ),
)

Before:

coords = {
    "geo": ["A", "B"], 
}
prior = fourier.sample_prior(coords=coords)
curve = fourier.sample_curve(prior)
fourier.plot_curve(curve.sel(geo="A").reset_coords("geo", drop=True))

After:

prior = fourier.sample_prior(coords=coords)
curve = fourier.sample_curve(prior)
fourier.plot_curve(curve.sel(geo="A"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers MMM
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant