BaseDelayedSaturatedMMM.build_model#

BaseDelayedSaturatedMMM.build_model(X, y, **kwargs)[source]#

Builds a probabilistic model using PyMC for marketing mix modeling.

The model incorporates channels, control variables, and Fourier components, applying adstock and saturation transformations to the channel data. The final model is constructed with multiple factors contributing to the response variable.

Parameters:
  • X (pd.DataFrame) – The input data for the model, which should include columns for channels, control variables (if applicable), and Fourier components (if applicable).

  • y (Union[pd.Series, np.ndarray]) – The target/response variable for the modeling.

  • **kwargs (dict) – Additional keyword arguments that might be required by underlying methods or utilities.

  • Set (Attributes)

  • ---------------

  • model (pm.Model) – The PyMC model object containing all the defined stochastic and deterministic variables.

Return type:

None

Examples

custom_config = {

‘intercept’: {‘dist’: ‘Normal’, ‘kwargs’: {‘mu’: 0, ‘sigma’: 2}}, ‘beta_channel’: {‘dist’: ‘LogNormal’, ‘kwargs’: {‘mu’: 1, ‘sigma’: 3}}, ‘alpha’: {‘dist’: ‘Beta’, ‘kwargs’: {‘alpha’: 1, ‘beta’: 3}}, ‘lam’: {‘dist’: ‘Gamma’, ‘kwargs’: {‘alpha’: 3, ‘beta’: 1}}, ‘likelihood’: {‘dist’: ‘Normal’,

‘kwargs’: {‘sigma’: {‘dist’: ‘HalfNormal’, ‘kwargs’: {‘sigma’: 2}}}

}, ‘gamma_control’: {‘dist’: ‘Normal’, ‘kwargs’: {‘mu’: 0, ‘sigma’: 2}}, ‘gamma_fourier’: {‘dist’: ‘Laplace’, ‘kwargs’: {‘mu’: 0, ‘b’: 1}}

}

model = DelayedSaturatedMMM(

date_column=”date_week”, channel_columns=[“x1”, “x2”], control_columns=[

“event_1”, “event_2”, “t”,

], adstock_max_lag=8, yearly_seasonality=2, model_config=custom_config,

)