From 18e7841c2f9565a4f26a1448acd6ec9a2b4420f4 Mon Sep 17 00:00:00 2001 From: Will Dean <57733339+wd60622@users.noreply.github.com> Date: Mon, 22 Jul 2024 12:40:44 +0200 Subject: [PATCH] specify 0.9.0 as deprecation version (#849) --- README.md | 15 ++++++++------- pymc_marketing/mmm/components/adstock.py | 12 ++++++++++-- pymc_marketing/mmm/delayed_saturated_mmm.py | 13 +++++++++++-- tests/mmm/test_delayed_saturated_mmm.py | 4 +++- 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index f1e6871c..267578df 100644 --- a/README.md +++ b/README.md @@ -72,14 +72,19 @@ Leverage our Bayesian MMM API to tailor your marketing strategies effectively. L ```python import pandas as pd -from pymc_marketing.mmm import MMM + +from pymc_marketing.mmm import ( + GeometricAdstock, + LogisticSaturation, + MMM, +) data_url = "https://raw.githubusercontent.com/pymc-labs/pymc-marketing/main/data/mmm_example.csv" data = pd.read_csv(data_url, parse_dates=["date_week"]) mmm = MMM( - adstock="geometric", - saturation="logistic", + adstock=GeometricAdstock(l_max=8), + saturation=LogisticSaturation(), date_column="date_week", channel_columns=["x1", "x2"], control_columns=[ @@ -87,7 +92,6 @@ mmm = MMM( "event_2", "t", ], - adstock_max_lag=8, yearly_seasonality=2, ) ``` @@ -111,9 +115,6 @@ Once the model is fitted, we can further optimize our budget allocation as we ar Explore a hands-on [simulated example](https://pymc-marketing.readthedocs.io/en/stable/notebooks/mmm/mmm_example.html) for more insights into MMM with PyMC-Marketing. -${\color{red}\textbf{Warning!}}$ We will deprecate the `DelayedSaturatedMMM` class in the next releases. -Please use the `MMM` class instead. - ### Essential Reading for Marketing Mix Modeling (MMM) - [Bayesian Media Mix Modeling for Marketing Optimization](https://www.pymc-labs.com/blog-posts/bayesian-media-mix-modeling-for-marketing-optimization/) diff --git a/pymc_marketing/mmm/components/adstock.py b/pymc_marketing/mmm/components/adstock.py index 49832733..dd11fed9 100644 --- a/pymc_marketing/mmm/components/adstock.py +++ b/pymc_marketing/mmm/components/adstock.py @@ -332,7 +332,10 @@ def __init__( l_max=l_max, normalize=normalize, mode=mode, priors=priors, prefix=prefix ) - msg = f"Use the Weibull{kind}Adstock class instead for better default priors." + msg = ( + f"Use the Weibull{kind}Adstock class instead for better default priors. " + "This class will deprecate in 0.9.0." + ) warnings.warn( msg, UserWarning, @@ -383,8 +386,13 @@ def _get_adstock_function( ) if kwargs: + msg = ( + "The preferred method of initializing a " + "lagging function is to use the class directly. " + "String support will deprecate in 0.9.0." + ) warnings.warn( - "The preferred method of initializing a lagging function is to use the class directly.", + msg, DeprecationWarning, stacklevel=1, ) diff --git a/pymc_marketing/mmm/delayed_saturated_mmm.py b/pymc_marketing/mmm/delayed_saturated_mmm.py index 74366e88..5db0b666 100644 --- a/pymc_marketing/mmm/delayed_saturated_mmm.py +++ b/pymc_marketing/mmm/delayed_saturated_mmm.py @@ -173,8 +173,12 @@ def __init__( self.adstock_first = adstock_first if adstock_max_lag is not None: + msg = ( + "The `adstock_max_lag` parameter is deprecated and will be removed in 0.9.0. " + "Use the `adstock` parameter directly" + ) warnings.warn( - "The `adstock_max_lag` parameter is deprecated. Use `adstock` directly", + msg, DeprecationWarning, stacklevel=1, ) @@ -2242,8 +2246,13 @@ def __init__( Warns that MMM class should be used instead and returns an instance of MMM with geometric adstock and logistic saturation. """ + msg = ( + "The DelayedSaturatedMMM class is deprecated and " + "will be removed in 0.9.0. " + "Please use the MMM class instead." + ) warnings.warn( - "The DelayedSaturatedMMM class is deprecated. Please use the MMM class instead.", + msg, DeprecationWarning, stacklevel=1, ) diff --git a/tests/mmm/test_delayed_saturated_mmm.py b/tests/mmm/test_delayed_saturated_mmm.py index 25823976..fe3dd0be 100644 --- a/tests/mmm/test_delayed_saturated_mmm.py +++ b/tests/mmm/test_delayed_saturated_mmm.py @@ -1000,8 +1000,10 @@ def test_add_lift_test_measurements_no_model() -> None: def test_delayed_saturated_mmm_raises_deprecation_warning() -> None: + match = "The DelayedSaturatedMMM class is deprecated and will be removed in 0.9.0" with pytest.warns( - DeprecationWarning, match="The DelayedSaturatedMMM class is deprecated" + DeprecationWarning, + match=match, ): DelayedSaturatedMMM( date_column="date",