DelayedSaturatedMMM#
- class pymc_marketing.mmm.delayed_saturated_mmm.DelayedSaturatedMMM(date_column, channel_columns, adstock_max_lag, time_varying_intercept=False, time_varying_media=False, model_config=None, sampler_config=None, validate_data=True, control_columns=None, yearly_seasonality=None, adstock_first=True, **kwargs)[source]#
Methods
DelayedSaturatedMMM.__init__(date_column, ...)Wrapper function for DelayedSaturatedMMM class initializer.
Add lift tests to the model.
DelayedSaturatedMMM.allocate_budget_to_maximize_response(...)Allocate the given budget to maximize the response over a specified time period.
DelayedSaturatedMMM.build_model(X, y, **kwargs)Builds a probabilistic model using PyMC for marketing mix modeling.
Evaluate the channel contribution for a given channel data and a fitted model, ie.
DelayedSaturatedMMM.compute_channel_contribution_original_scale()Compute the channel contributions in the original scale of the target variable.
DelayedSaturatedMMM.compute_mean_contributions_over_time([...])Get the contributions of each channel over time.
DelayedSaturatedMMM.fit(X[, y, progressbar, ...])Fit a model using the data passed as a parameter.
DelayedSaturatedMMM.format_recovered_transformation_parameters([...])Format the recovered transformation parameters for each channel.
Transforms channel input into target contributions of each channel.
DelayedSaturatedMMM.get_channel_contributions_forward_pass_grid(...)Generate a grid of scaled channel contributions for a given grid of shared values.
DelayedSaturatedMMM.get_errors([original_scale])Get model errors posterior distribution.
DelayedSaturatedMMM.get_params([deep])Get all the model parameters needed to instantiate a copy of the model, not including training data.
Return the target transformer pipeline used for preprocessing the target variable.
DelayedSaturatedMMM.graphviz(**kwargs)DelayedSaturatedMMM.load(fname)Creates a MMM instance from a file, instantiating the model with the saved original input parameters.
Return the upcoming contributions for a given spend.
DelayedSaturatedMMM.plot_allocated_contribution_by_channel(samples)Plot the allocated contribution by channel with uncertainty intervals.
Plot the budget allocation and channel contributions.
DelayedSaturatedMMM.plot_channel_contribution_share_hdi([...])Plot the share of channel contributions in a forest plot.
Plots a grid of scaled channel contributions for a given grid of share values.
Plot the posterior distribution of a specific parameter for each channel.
Plot the target variable and the posterior predictive model components in the scaled space.
Plots the direct contribution curves for each marketing channel.
Plot model errors by taking the difference between true values and predicted.
DelayedSaturatedMMM.plot_grouped_contribution_breakdown_over_time([...])Plot a time series area chart for all channel contributions.
Plot the upcoming sales for a given spend amount.
Plot posterior distribution from the model fit.
DelayedSaturatedMMM.plot_waterfall_components_decomposition([...])This function creates a waterfall plot.
DelayedSaturatedMMM.predict(X_pred[, ...])Uses model to predict on unseen data and return point prediction of all the samples.
Generate posterior predictive samples on unseen data.
DelayedSaturatedMMM.predict_proba(X_pred[, ...])Alias for
predict_posterior, for consistency with scikit-learn probabilistic estimators.DelayedSaturatedMMM.preprocess(target, data)Preprocess the provided data according to the specified target.
Sample from the model's posterior predictive distribution.
Sample from the model's prior predictive distribution.
DelayedSaturatedMMM.save(fname)Save the model's inference data to a file.
DelayedSaturatedMMM.set_idata_attrs([idata])Set attributes on an InferenceData object.
DelayedSaturatedMMM.set_params(**params)Set all the model parameters needed to instantiate the model, not including training data.
DelayedSaturatedMMM.validate(target, data)Validates the input data based on the specified target type.
Attributes
Xdefault_model_configReturns a class default config dict for model builder if no model_config is provided on class initialization Useful for understanding structure of required model_config to allow its customization by users Examples -------- >>> @classmethod >>> def default_model_config(self): >>> Return { >>> 'a' : { >>> 'loc': 7, >>> 'scale' : 3 >>> }, >>> 'b' : { >>> 'loc': 3, >>> 'scale': 5 >>> } >>> 'obs_error': 2 >>> }
default_sampler_configReturns a class default sampler dict for model builder if no sampler_config is provided on class initialization Useful for understanding structure of required sampler_config to allow its customization by users Examples -------- >>> @classmethod >>> def default_sampler_config(self): >>> Return { >>> 'draws': 1_000, >>> 'tune': 1_000, >>> 'chains': 1, >>> 'target_accept': 0.95, >>> }
fit_resultidGenerate a unique hash value for the model.
methodsoutput_varDefines target variable for the model
posterior_predictivepreprocessing_methodsA property that provides preprocessing methods for features ("X") and the target variable ("y").
priorprior_predictivevalidation_methodsA property that provides validation methods for features ("X") and the target variable ("y").
versionytarget_transformerchannel_columnscontrol_columnsmodeldate_column