ModelBuilder#
- class pymc_marketing.model_builder.ModelBuilder(model_config=None, sampler_config=None)[source]#
ModelBuilder can be used to provide an easy-to-use API (similar to scikit-learn) for models and help with deployment.
Methods
ModelBuilder.__init__([model_config, ...])Initializes model configuration and sampler configuration for the model
ModelBuilder.build_model(X, y, **kwargs)Creates an instance of pm.Model based on provided data and model_config, and attaches it to self.
ModelBuilder.fit(X[, y, progressbar, ...])Fit a model using the data passed as a parameter.
ModelBuilder.get_params([deep])Get all the model parameters needed to instantiate a copy of the model, not including training data.
ModelBuilder.load(fname)Creates a ModelBuilder instance from a file,
ModelBuilder.predict(X_pred[, extend_idata])Uses model to predict on unseen data and return point prediction of all the samples.
ModelBuilder.predict_posterior(X_pred[, ...])Generate posterior predictive samples on unseen data.
ModelBuilder.predict_proba(X_pred[, ...])Alias for
predict_posterior, for consistency with scikit-learn probabilistic estimators.Sample from the model's posterior predictive distribution.
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.set_params(**params)Set all the model parameters needed to instantiate the model, not including training data.
Attributes
Xdefault_model_configReturns a class default config dict for model builder if no model_config is provided on class initialization Useful for understanding structure of required model_config to allow its customization by users
default_sampler_configReturns a class default sampler dict for model builder if no sampler_config is provided on class initialization Useful for understanding structure of required sampler_config to allow its customization by users Examples -------- >>> @classmethod >>> def default_sampler_config(self): >>> Return { >>> 'draws': 1_000, >>> 'tune': 1_000, >>> 'chains': 1, >>> 'target_accept': 0.95, >>> }
idGenerate a unique hash value for the model.
output_varReturns the name of the output variable of the model.
versiony