Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

document lift test requirements with time_varying_media=True #1287

Open
wd60622 opened this issue Dec 17, 2024 · 0 comments
Open

document lift test requirements with time_varying_media=True #1287

wd60622 opened this issue Dec 17, 2024 · 0 comments
Labels
docs Improvements or additions to documentation lift tests MMM

Comments

@wd60622
Copy link
Contributor

wd60622 commented Dec 17, 2024

Using the time_varying_media=True parameter requires that the date is provided in the df_lift_test DataFrame.

Example to produce the error:

import pandas as pd

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=GeometricAdstock(l_max=8),
    saturation=LogisticSaturation(),
    date_column="date_week",
    channel_columns=["x1", "x2"],
    control_columns=[
        "event_1",
        "event_2",
        "t",
    ],
    time_varying_media=True,
)

X = data.drop("y", axis=1)
y = data["y"]
mmm.build_model(X, y)

# This is the lift test format with time_varying_media=False
df_lift_test = pd.DataFrame(
    {
        "channel": ["x1"],
        "x": [1],
        "delta_x": [0.1],
        "delta_y": [0.1],
        "sigma": [0.05],
    }
)


mmm.add_lift_test_measurements(df_lift_test)
# MissingValueError: "The value ['date'] is missing of the required ['date', 'channel']"
@wd60622 wd60622 added docs Improvements or additions to documentation MMM lift tests and removed Needs Triage labels Dec 17, 2024
@wd60622 wd60622 modified the milestone: 0.12.0 Dec 29, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
docs Improvements or additions to documentation lift tests MMM
Projects
None yet
Development

No branches or pull requests

1 participant