Open
Description
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']"
Activity