MMMModelBuilder#

class pymc_marketing.mmm.base.MMMModelBuilder(date_column, channel_columns, model_config=None, sampler_config=None, **kwargs)[source]#

Methods

MMMModelBuilder.__init__(date_column, ...[, ...])

Initializes model configuration and sampler configuration for the model

MMMModelBuilder.build_model(X, y, **kwargs)

Creates an instance of pm.Model based on provided data and model_config, and attaches it to self.

MMMModelBuilder.compute_channel_contribution_original_scale()

Compute the channel contributions in the original scale of the target variable.

MMMModelBuilder.compute_mean_contributions_over_time([...])

Get the contributions of each channel over time.

MMMModelBuilder.fit(X[, y, progressbar, ...])

Fit a model using the data passed as a parameter.

MMMModelBuilder.get_errors([original_scale])

Get model errors posterior distribution.

MMMModelBuilder.get_params([deep])

Get all the model parameters needed to instantiate a copy of the model, not including training data.

MMMModelBuilder.get_target_transformer()

Return the target transformer pipeline used for preprocessing the target variable.

MMMModelBuilder.graphviz(**kwargs)

MMMModelBuilder.load(fname)

Creates a ModelBuilder instance from a file, Loads inference data for the model.

MMMModelBuilder.plot_channel_contribution_share_hdi([...])

Plot the share of channel contributions in a forest plot.

MMMModelBuilder.plot_components_contributions(...)

Plot the target variable and the posterior predictive model components in the scaled space.

MMMModelBuilder.plot_errors([original_scale, ax])

Plot model errors by taking the difference between true values and predicted.

MMMModelBuilder.plot_grouped_contribution_breakdown_over_time([...])

Plot a time series area chart for all channel contributions.

MMMModelBuilder.plot_posterior_predictive([...])

Plot posterior distribution from the model fit.

MMMModelBuilder.plot_prior_predictive(...)

MMMModelBuilder.plot_waterfall_components_decomposition([...])

This function creates a waterfall plot.

MMMModelBuilder.predict(X_pred[, extend_idata])

Uses model to predict on unseen data and return point prediction of all the samples.

MMMModelBuilder.predict_posterior(X_pred[, ...])

Generate posterior predictive samples on unseen data.

MMMModelBuilder.predict_proba(X_pred[, ...])

Alias for predict_posterior, for consistency with scikit-learn probabilistic estimators.

MMMModelBuilder.preprocess(target, data)

Preprocess the provided data according to the specified target.

MMMModelBuilder.sample_posterior_predictive(X_pred)

Sample from the model's posterior predictive distribution.

MMMModelBuilder.sample_prior_predictive(X_pred)

Sample from the model's prior predictive distribution.

MMMModelBuilder.save(fname)

Save the model's inference data to a file.

MMMModelBuilder.set_idata_attrs([idata])

Set attributes on an InferenceData object.

MMMModelBuilder.set_params(**params)

Set all the model parameters needed to instantiate the model, not including training data.

MMMModelBuilder.validate(target, data)

Validates the input data based on the specified target type.

Attributes

X

default_model_config

Returns 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_config

Returns 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_result

id

Generate a unique hash value for the model.

methods

output_var

Returns the name of the output variable of the model.

posterior_predictive

preprocessing_methods

A property that provides preprocessing methods for features ("X") and the target variable ("y").

prior

prior_predictive

validation_methods

A property that provides validation methods for features ("X") and the target variable ("y").

version

y

model