From 53f1f7cc4900f7349fb4b691b76a32f985a11140 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 4 Nov 2025 21:09:03 +0000 Subject: [PATCH 1/4] Initial plan From 85a3fe253607eda0558c055c1e8bc851d981a0e1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 4 Nov 2025 21:12:45 +0000 Subject: [PATCH 2/4] Convert code-block to plot directives for Fourier examples that generate images Co-authored-by: juanitorduz <22996444+juanitorduz@users.noreply.github.com> --- pymc_marketing/mmm/fourier.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pymc_marketing/mmm/fourier.py b/pymc_marketing/mmm/fourier.py index 6a6d6c44e..efd1a0d93 100644 --- a/pymc_marketing/mmm/fourier.py +++ b/pymc_marketing/mmm/fourier.py @@ -52,7 +52,9 @@ -------- Use yearly fourier seasonality for custom Marketing Mix Model. -.. code-block:: python +.. plot:: + :context: close-figs + :nofigs: import pandas as pd import pymc as pm @@ -70,7 +72,8 @@ Plot the prior fourier seasonality trend. -.. code-block:: python +.. plot:: + :context: close-figs import matplotlib.pyplot as plt @@ -91,7 +94,9 @@ Even make it hierarchical... -.. code-block:: python +.. plot:: + :context: close-figs + :nofigs: from pymc_marketing.mmm import YearlyFourier from pymc_extras.prior import Prior @@ -107,7 +112,8 @@ All the plotting will still work! Just pass any coords. -.. code-block:: python +.. plot:: + :context: close-figs import matplotlib.pyplot as plt From 3ed3567234bf5d356797383d2aab3628087cf424 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 4 Nov 2025 21:53:11 +0000 Subject: [PATCH 3/4] Revert setup code blocks to code-block directive per review feedback Co-authored-by: juanitorduz <22996444+juanitorduz@users.noreply.github.com> --- pymc_marketing/mmm/fourier.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pymc_marketing/mmm/fourier.py b/pymc_marketing/mmm/fourier.py index efd1a0d93..2fce5be74 100644 --- a/pymc_marketing/mmm/fourier.py +++ b/pymc_marketing/mmm/fourier.py @@ -52,9 +52,7 @@ -------- Use yearly fourier seasonality for custom Marketing Mix Model. -.. plot:: - :context: close-figs - :nofigs: +.. code-block:: python import pandas as pd import pymc as pm @@ -94,9 +92,7 @@ Even make it hierarchical... -.. plot:: - :context: close-figs - :nofigs: +.. code-block:: python from pymc_marketing.mmm import YearlyFourier from pymc_extras.prior import Prior From 582e9c225a8a60509a07a81ffe9e99ea80ca436f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 4 Nov 2025 22:23:54 +0000 Subject: [PATCH 4/4] Add setup code to plot directives to fix rendering issues Co-authored-by: juanitorduz <22996444+juanitorduz@users.noreply.github.com> --- pymc_marketing/mmm/fourier.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/pymc_marketing/mmm/fourier.py b/pymc_marketing/mmm/fourier.py index 2fce5be74..f7ac7496e 100644 --- a/pymc_marketing/mmm/fourier.py +++ b/pymc_marketing/mmm/fourier.py @@ -73,8 +73,21 @@ .. plot:: :context: close-figs + import pandas as pd + import pymc as pm import matplotlib.pyplot as plt + from pymc_marketing.mmm import YearlyFourier + + yearly = YearlyFourier(n_order=3) + + dates = pd.date_range("2023-01-01", periods=52, freq="W-MON") + + dayofyear = dates.dayofyear.to_numpy() + + with pm.Model() as model: + fourier_trend = yearly.apply(dayofyear) + prior = yearly.sample_prior() curve = yearly.sample_curve(prior) yearly.plot_curve(curve) @@ -113,6 +126,18 @@ import matplotlib.pyplot as plt + from pymc_marketing.mmm import YearlyFourier + from pymc_extras.prior import Prior + + # "fourier" is the default prefix! + prior = Prior( + "Laplace", + mu=Prior("Normal", dims="fourier"), + b=Prior("HalfNormal", sigma=0.1, dims="fourier"), + dims=("fourier", "hierarchy"), + ) + yearly = YearlyFourier(n_order=3, prior=prior) + coords = {"hierarchy": ["A", "B", "C"]} prior = yearly.sample_prior(coords=coords) curve = yearly.sample_curve(prior)