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.
Convert the model configuration and sampler configuration from the attributes to keyword arguments.
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
()Compute the channel contributions in the original scale of the target variable.
Get the contributions of each channel over time.
Create attributes for the inference data.
BaseValidateMMM.fit
(X[, y, progressbar, ...])Fit a model using the data passed as a parameter.
BaseValidateMMM.get_errors
([original_scale])Get model errors posterior distribution.
BaseValidateMMM.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.
BaseValidateMMM.graphviz
(**kwargs)Get the graphviz representation of the model.
BaseValidateMMM.load
(fname)Create a ModelBuilder instance from a file.
Plot the share of channel contributions in a forest plot.
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.
Plot posterior distribution from the model fit.
Plot the prior predictive data.
BaseValidateMMM.plot_waterfall_components_decomposition
([...])Create a waterfall plot.
BaseValidateMMM.predict
(X_pred[, extend_idata])Use a model to predict on unseen data and return point prediction of all the samples.
BaseValidateMMM.predict_posterior
(X_pred[, ...])Generate posterior predictive samples on unseen data.
BaseValidateMMM.predict_proba
(X_pred[, ...])Alias for
predict_posterior
, for consistency with scikit-learn probabilistic estimators.BaseValidateMMM.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.
BaseValidateMMM.save
(fname)Save the model's inference data to a file.
BaseValidateMMM.set_idata_attrs
([idata])Set attributes on an InferenceData object.
BaseValidateMMM.set_params
(**params)Set all the model parameters needed to instantiate the model, not including training data.
BaseValidateMMM.validate
(target, data)Validate the input data based on the specified target type.
Validate the channel columns.
Validate the date column.
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 data.
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_predictive
Get the posterior predictive data.
preprocessing_methods
A property that provides preprocessing methods for features ("X") and the target variable ("y").
prior
Get the prior data.
prior_predictive
Get the prior predictive data.
validation_methods
A property that provides validation methods for features ("X") and the target variable ("y").
version
y
model
date_column
channel_columns