MMM#
- class pymc_marketing.mmm.base.MMM(date_column, channel_columns, model_config=None, sampler_config=None, **kwargs)[source]#
Methods
MMM.__init__(date_column, channel_columns[, ...])Initializes model configuration and sampler configuration for the model
MMM.build_model(X, y, **kwargs)Creates an instance of pm.Model based on provided data and model_config, and attaches it to self.
- rtype:
DataArray
MMM.compute_channel_curve_optimization_parameters_original_scale([...])Experimental: Estimate the parameters for the saturating function of each channel's contribution.
Get the contributions of each channel over time.
MMM.fit(X[, y, progressbar, ...])Fit a model using the data passed as a parameter.
MMM.get_errors([original_scale])Get model errors posterior distribution.
MMM.get_params([deep])Get all the model parameters needed to instantiate a copy of the model, not including training data.
- rtype:
Pipeline
MMM.graphviz(**kwargs)MMM.load(fname)Creates a ModelBuilder instance from a file, Loads inference data for the model.
Experimental: Optimize the allocation of a given total budget across multiple channels to maximize the expected contribution.
MMM.plot_budget_scenearios(*, base_data[, ...])Experimental: Plots the budget and contribution bars side by side for multiple scenarios.
- rtype:
Figure
MMM.plot_channel_parameter(param_name, ...)- rtype:
Figure
MMM.plot_components_contributions(**plt_kwargs)- rtype:
Figure
Plots the direct contribution curves for each marketing channel.
MMM.plot_errors([original_scale, ax])Plot model errors by taking the difference between true values and predicted.
Plot a time series area chart for all channel contributions.
Plot posterior distribution from the model fit.
MMM.plot_prior_predictive([samples])- rtype:
Figure
This function creates a waterfall plot.
MMM.predict(X_pred[, extend_idata])Uses model to predict on unseen data and return point prediction of all the samples.
MMM.predict_posterior(X_pred[, ...])Generate posterior predictive samples on unseen data.
MMM.predict_proba(X_pred[, extend_idata, ...])Alias for
predict_posterior, for consistency with scikit-learn probabilistic estimators.MMM.preprocess(target, data)Preprocess the provided data according to the specified target.
MMM.sample_posterior_predictive(X_pred[, ...])Sample from the model's posterior predictive distribution.
MMM.sample_prior_predictive(X_pred[, ...])Sample from the model's prior predictive distribution.
MMM.save(fname)Save the model's inference data to a file.
MMM.set_idata_attrs([idata])Set attributes on an InferenceData object.
MMM.set_params(**params)Set all the model parameters needed to instantiate the model, not including training data.
MMM.validate(target, data)Validates the input data based on the specified target type.
- rtype:
None
MMM.validate_date_col(data)- rtype:
None
MMM.validate_target(data)- rtype:
None
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 .
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 .
fit_resultidGenerate a unique hash value for the model.
methodsoutput_varReturns the name of the output variable of 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").
versionymodeldate_columnchannel_columns