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.
Convert the model configuration and sampler configuration from the attributes to keyword arguments.
Build model from the InferenceData object.
ModelBuilder.build_model(X, y, **kwargs)Create an instance of
pm.Modelbased on provided data and model_config.Create the fit_data group based on the input data.
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.
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.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.
ModelBuilder.table(**model_table_kwargs)Get the summary table of the model.
Attributes
Xdefault_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.
output_varReturns the name of the output variable of the model.
posteriorposterior_predictivepredictionspriorprior_predictiveversiony