Parameter#
- class pymc_marketing.terms.Parameter(name, prior=<factory>)[source]#
Named free parameter (scalar or dimensional via
prior.dims).Parameteris the general-purpose leaf for free random variables.Interceptis a convenience alias that defaultsnameto"intercept"; both share the same lifecycle.Each parameter in the same
pm.Modelmust have a uniquename. Two parameters with the same name (even in different expression trees, e.g., amuexpression and asigmaexpression) will clash whenbuild_paramcreates the variables.- Parameters:
- name
str Name for the PyMC variable (required).
- prior
VariableFactory Prior distribution for the parameter. Any
VariableFactory(Prior,Censored,Scaled, custom) is accepted. When the prior carriesdims(e.g.Prior(..., dims="cohort")),get_coordswill extract those coordinates from the dataset.
- name
Examples
from pymc_extras.prior import Prior from pymc_marketing.terms import ( Parameter, Dot, Intercept, collect_coords, register_data, build_param, ) # scalar mu = Parameter("mu") + Dot(var_name="x", prior=Prior("Normal", dims="feature")) # dimensional (cohort) alpha = Parameter("alpha_scale", prior=Prior("HalfNormal", dims="cohort")) # same concept, GLM sugar intercept = Intercept("intercept") # defaults to name="intercept"
Methods
Parameter.__init__(name[, prior])Add coordinates to the model during
register_data.Build a free parameter variable.
Parameter.from_dict(data)Reconstruct a parameter from its serialized form.
Collect coordinates from
prior.dimspresent in the dataset.Register shared data variables as
pmd.Data.Parameter.set_data(ds[, model])Update shared data variables for out-of-sample prediction.
Parameter.to_dict([_orig])Attributes