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

Specify 0.9.0 as deprecation version for recent MMM changes #849

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,26 @@ 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=[
"event_1",
"event_2",
"t",
],
adstock_max_lag=8,
yearly_seasonality=2,
)
```
Expand All @@ -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/)
Expand Down
12 changes: 10 additions & 2 deletions pymc_marketing/mmm/components/adstock.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,10 @@
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,
Expand Down Expand Up @@ -383,8 +386,13 @@
)

if kwargs:
msg = (

Check warning on line 389 in pymc_marketing/mmm/components/adstock.py

View check run for this annotation

Codecov / codecov/patch

pymc_marketing/mmm/components/adstock.py#L389

Added line #L389 was not covered by tests
"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,
)
Expand Down
13 changes: 11 additions & 2 deletions pymc_marketing/mmm/delayed_saturated_mmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,12 @@
self.adstock_first = adstock_first

if adstock_max_lag is not None:
msg = (

Check warning on line 176 in pymc_marketing/mmm/delayed_saturated_mmm.py

View check run for this annotation

Codecov / codecov/patch

pymc_marketing/mmm/delayed_saturated_mmm.py#L176

Added line #L176 was not covered by tests
"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,
)
Expand Down Expand Up @@ -2242,8 +2246,13 @@
Warns that MMM class should be used instead and returns an instance of MMM with
geometric adstock and logistic saturation.
"""
msg = (

Check warning on line 2249 in pymc_marketing/mmm/delayed_saturated_mmm.py

View check run for this annotation

Codecov / codecov/patch

pymc_marketing/mmm/delayed_saturated_mmm.py#L2249

Added line #L2249 was not covered by tests
"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,
)
Expand Down
4 changes: 3 additions & 1 deletion tests/mmm/test_delayed_saturated_mmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading