WeibullCDFAdstock#
- class pymc_marketing.mmm.components.adstock.WeibullCDFAdstock(l_max=FieldInfo(annotation=NoneType, required=True, description='Maximum lag for the adstock transformation.', metadata=[Gt(gt=0)]), normalize=FieldInfo(annotation=NoneType, required=False, default=True, description='Whether to normalize the adstock values.'), mode=FieldInfo(annotation=NoneType, required=False, default=<ConvMode.After: 'After'>, description='Convolution mode.'), priors=FieldInfo(annotation=NoneType, required=False, default=None, description='Priors for the parameters.'), prefix=FieldInfo(annotation=NoneType, required=False, default=None, description='Prefix for the parameters.'))[source]#
Wrapper around weibull adstock with CDF function.
Calls
pymc_marketing.mmm.transformers.weibull_adstock()withtype=WeibullType.CDFand the wrapper’sl_max,normalizeandmodesettings.- Parameters:
- lam
tensor Scale parameter of the Weibull distribution; must be positive. Default prior:
Prior("Gamma", mu=2, sigma=2.5).- k
tensor Shape parameter of the Weibull distribution; must be positive. Default prior:
Prior("Gamma", mu=2, sigma=2.5).- .. plot::
- context:
close-figs
import matplotlib.pyplot as plt import numpy as np from pymc_marketing.mmm import WeibullCDFAdstock
rng = np.random.default_rng(0)
adstock = WeibullCDFAdstock(l_max=10) prior = adstock.sample_prior(random_seed=rng) curve = adstock.sample_curve(prior) adstock.plot_curve(curve, random_seed=rng) plt.show()
- lam
Methods
WeibullCDFAdstock.__init__([l_max, ...])WeibullCDFAdstock.apply(x, *[, dims, ...])Call within a model context.
Reconstruct an adstock transformation from a dict.
WeibullCDFAdstock.function(x, lam, k, *, dim)Weibull adstock function.
WeibullCDFAdstock.plot_curve(curve[, ...])Plot curve HDI and samples.
WeibullCDFAdstock.plot_curve_hdi(curve[, ...])Plot the HDI of the curve.
Plot samples from the curve.
WeibullCDFAdstock.sample_curve(parameters[, ...])Sample the adstock transformation given parameters.
WeibullCDFAdstock.sample_prior([coords])Sample the priors for the transformation.
Set the dims for all priors.
WeibullCDFAdstock.to_dict([_orig])Convert the adstock transformation to a dictionary.
WeibullCDFAdstock.update_priors(priors)Update the priors for a function after initialization.
Return a copy with default prior dims (dims=None) set to
dimsinstead.Return a copy with updated priors.
Attributes
combined_dimsGet the combined dims for all the parameters.
default_priorsfunction_priorsGet the priors for the function.
model_configMapping from variable name to prior for the model.
prefixpriorsGet the priors for the function.
variable_mappingMapping from parameter name to variable name in the model.