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.
Convert the model configuration and sampler configuration from the attributes to keyword arguments.
Build the model from the InferenceData object.
ModelBuilder.build_model(**kwargs)Create an instance of
pm.Modelbased on provided data and model_config.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.
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_configReturn a class default configuration dictionary.
default_sampler_configReturn a class default sampler configuration dictionary.
fit_resultGet the posterior fit_result.
idGenerate a unique hash value for the model.
posteriorposterior_predictivepredictionspriorprior_predictiveversionidatasampler_configmodel_config