prior#
Class that represents a prior distribution.
The Prior class is a wrapper around PyMC distributions that allows the user
to create outside of the PyMC model.
This is the alternative to using the dictionaries in PyMC-Marketing models.
Examples#
Create a normal prior.
from pymc_marketing.prior import Prior
normal = Prior("Normal")
Create a hierarchical normal prior by using distributions for the parameters and specifying the dims.
hierarchical_normal = Prior(
"Normal",
mu=Prior("Normal"),
sigma=Prior("HalfNormal"),
dims="channel",
)
Create a non-centered hierarchical normal prior with the centered parameter.
non_centered_hierarchical_normal = Prior(
"Normal",
mu=Prior("Normal"),
sigma=Prior("HalfNormal"),
dims="channel",
# Only change needed to make it non-centered
centered=False,
)
Create a hierarchical beta prior by using Beta distribution, distributions for the parameters, and specifying the dims.
hierarchical_beta = Prior(
"Beta",
alpha=Prior("HalfNormal"),
beta=Prior("HalfNormal"),
dims="channel",
)
Create a transformed hierarchical normal prior by using the transform
parameter.
transformed_hierarchical_normal = Prior(
"Normal",
mu=Prior("Normal"),
sigma=Prior("HalfNormal"),
transform="sigmoid",
dims="channel",
)
Functions
|
Wrapper to act like the previous |
|
Take a tensor of dims |
Classes
|
A class to represent a prior distribution. |
Exceptions
|
Error for when 'mu' is present in Prior. |
|
Error for when an unknown transform is used. |
|
Error for when an unsupported distribution is used. |
|
The follow parameterization is not supported. |
|
Error for when the shape of the hierarchical variable is not supported. |