ModelBuilder#

class pymc_marketing.model_builder.ModelBuilder(model_config=None, sampler_config=None)[source]#

Base class for building PyMC-Marketing models.

Child classes must implement the following methods: - default_model_config: Returns a dictionary for default model configuration. - default_sampler_config: Returns a dictionary for default sampler configuration. - build_model: Builds the model based on the provided data and model configuration. - build_from_idata: Builds the model from an InferenceData object. Needed for loading models. - fit: Fits the model based on the provided data and sampler configurations. - attrs_to_init_kwargs: Override to add additional init keyword arguments. - _serializable_model_config: Needed for saving and loading the model.

Methods

ModelBuilder.__init__([model_config, ...])

Initialize model configuration and sampler configuration for the model.

ModelBuilder.attrs_to_init_kwargs(attrs)

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

ModelBuilder.build_from_idata(idata)

Build the model from the InferenceData object.

ModelBuilder.build_model(**kwargs)

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

ModelBuilder.create_idata_attrs()

Create attributes for the inference data.

ModelBuilder.fit(**kwargs)

Fit a model using the data passed as a parameter.

ModelBuilder.graphviz(**kwargs)

Get the graphviz representation of the model.

ModelBuilder.idata_to_init_kwargs(idata)

Create the model configuration and sampler configuration from the InferenceData to keyword arguments.

ModelBuilder.load(fname[, check])

Create a ModelBuilder instance from a file.

ModelBuilder.load_from_idata(idata[, check])

Create a ModelBuilder instance from an InferenceData object.

ModelBuilder.save(fname, **kwargs)

Save the model's inference data to a file.

ModelBuilder.set_idata_attrs([idata])

Set attributes on an InferenceData object.

ModelBuilder.table(**model_table_kwargs)

Get the summary table of the model.

Attributes

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.

posterior

posterior_predictive

predictions

prior

prior_predictive

version

idata

sampler_config

model_config