BaseValidateMMM#

class pymc_marketing.mmm.base.BaseValidateMMM(date_column=FieldInfo(annotation=str, required=True, description='Column name of the date variable.'), channel_columns=FieldInfo(annotation=list[str], required=True, description='Column names of the media channel variables.', metadata=[MinLen(min_length=1)]), model_config=FieldInfo(annotation=Union[dict, NoneType], required=False, default=None, description='Model configuration.'), sampler_config=FieldInfo(annotation=Union[dict, NoneType], required=False, default=None, description='Sampler configuration.'))[source]#

Base class with some validation of the inputs.

Methods

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

Initialize model configuration and sampler configuration for the model.

BaseValidateMMM.attrs_to_init_kwargs(attrs)

Convert the model configuration and sampler configuration from the attributes to keyword arguments.

BaseValidateMMM.build_from_idata(idata)

Build model from the InferenceData object.

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

Create an instance of pm.Model based on provided data and model_config.

BaseValidateMMM.compute_channel_contribution_original_scale([prior])

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

BaseValidateMMM.compute_mean_contributions_over_time([...])

Get the contributions of each channel over time.

BaseValidateMMM.create_fit_data(X, y)

Create the fit_data group based on the input data.

BaseValidateMMM.create_idata_attrs()

Create attributes for the inference data.

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

Fit a model using the data passed as a parameter.

BaseValidateMMM.get_channel_contributions_share_samples([prior])

Get the share of channel contributions in the original scale of the target variable.

BaseValidateMMM.get_errors([original_scale])

Get model errors posterior distribution.

BaseValidateMMM.get_target_transformer()

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

BaseValidateMMM.graphviz(**kwargs)

Get the graphviz representation of the model.

BaseValidateMMM.load(fname)

Create a ModelBuilder instance from a file.

BaseValidateMMM.load_from_idata(idata)

Create a ModelBuilder instance from an InferenceData object.

BaseValidateMMM.plot_channel_contribution_share_hdi([...])

Plot the share of channel contributions in a forest plot.

BaseValidateMMM.plot_components_contributions(...)

Plot the target variable and the posterior predictive model components.

BaseValidateMMM.plot_errors([original_scale, ax])

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

BaseValidateMMM.plot_grouped_contribution_breakdown_over_time([...])

Plot a time series area chart for all channel contributions.

BaseValidateMMM.plot_posterior_predictive([...])

Plot the posterior predictive distribution from the model fit.

BaseValidateMMM.plot_prior_predictive([...])

Plot the prior predictive distribution from the model fit.

BaseValidateMMM.plot_prior_vs_posterior(var_name)

Plot the prior vs posterior distribution for a specified variable in a 3 columngrid layout.

BaseValidateMMM.plot_waterfall_components_decomposition([...])

Create a waterfall plot.

BaseValidateMMM.post_sample_model_transformation()

Perform transformation on the model after sampling.

BaseValidateMMM.predict([X, extend_idata])

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

BaseValidateMMM.predict_posterior([X, ...])

Generate posterior predictive samples on unseen data.

BaseValidateMMM.predict_proba([X, ...])

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

BaseValidateMMM.preprocess(target, data)

Preprocess the provided data according to the specified target.

BaseValidateMMM.sample_posterior_predictive([...])

Sample from the model's posterior predictive distribution.

BaseValidateMMM.sample_prior_predictive([X, ...])

Sample from the model's prior predictive distribution.

BaseValidateMMM.save(fname)

Save the model's inference data to a file.

BaseValidateMMM.set_idata_attrs([idata])

Set attributes on an InferenceData object.

BaseValidateMMM.validate(target, data)

Validate the input data based on the specified target type.

BaseValidateMMM.validate_channel_columns(data)

Validate the channel columns.

BaseValidateMMM.validate_date_col(data)

Validate the date column.

BaseValidateMMM.validate_target(data)

Validate the target column.

Attributes

X

default_model_config

Return a class default configuration dictionary.

default_sampler_config

Return a class default sampler configuration dictionary.

fit_result

Get the posterior fit_result.

id

Generate a unique hash value for the model.

methods

Get all methods of the object.

output_var

Returns the name of the output variable of the model.

posterior

posterior_predictive

predictions

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

date_column

channel_columns