ModelBuilder#

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

Base class for building models with PyMC-Marketing.

It provides an easy-to-use API (similar to scikit-learn) for models and help with deployment.

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 model from the InferenceData object.

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

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

ModelBuilder.create_fit_data(X, y)

Create the fit_data group based on the input data.

ModelBuilder.create_idata_attrs()

Create attributes for the inference data.

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

Fit a model using the data passed as a parameter.

ModelBuilder.graphviz(**kwargs)

Get the graphviz representation of the model.

ModelBuilder.load(fname)

Create a ModelBuilder instance from a file.

ModelBuilder.load_from_idata(idata)

Create a ModelBuilder instance from an InferenceData object.

ModelBuilder.post_sample_model_transformation()

Perform transformation on the model after sampling.

ModelBuilder.predict([X, extend_idata])

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

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

Generate posterior predictive samples on unseen data.

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

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

ModelBuilder.sample_posterior_predictive([...])

Sample from the model's posterior predictive distribution.

ModelBuilder.sample_prior_predictive([X, y, ...])

Sample from the model's prior predictive distribution.

ModelBuilder.save(fname)

Save the model's inference data to a file.

ModelBuilder.set_idata_attrs([idata])

Set attributes on an InferenceData object.

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.

output_var

Returns the name of the output variable of the model.

posterior

posterior_predictive

predictions

prior

prior_predictive

version

y