saturation#
Saturation transformations for the MMM model.
Each of these transformations is a subclass of
pymc_marketing.mmm.components.saturation.SaturationTransformation and defines a function
that takes media and return the saturated media. The parameters of the function
are the parameters of the saturation transformation.
Notes#
The wrapper classes in this module extend the transformer functions in
pymc_marketing.mmm.transformers with the priors needed to fit them in a model.
Several wrappers also introduce an extra scaling parameter that the underlying
transformer does not take, so the curve can reach a value other than the bounded
range of the transformer:
LogisticSaturation,InverseScaledLogisticSaturation,TanhSaturationBaselined,HillSaturation,RootSaturation, andNoSaturationmultiply the output bybeta.MichaelisMentenSaturation,TanhSaturation, andHillSaturationSigmoiddo not add an extra parameter because the underlying function already exposes the asymptote (alpha,b, orsigma).
See each class for the full list of parameters and their default priors.
Examples#
Create a new saturation transformation:
from pymc_marketing.mmm import SaturationTransformation
from pymc_extras.prior import Prior
from pymc_marketing.serialization import serialization
@serialization.register
class InfiniteReturns(SaturationTransformation):
def function(self, x, b):
return b * x
default_priors = {"b": Prior("HalfNormal", sigma=1)}
Plot the default priors for a saturation transformation:
from pymc_marketing.mmm import HillSaturation
import matplotlib.pyplot as plt
saturation = HillSaturation()
prior = saturation.sample_prior()
curve = saturation.sample_curve(prior)
saturation.plot_curve(curve)
plt.show()
Define a hierarchical saturation function with only hierarchical parameters for saturation parameter of logistic saturation.
from pymc_extras.prior import Prior
from pymc_marketing.mmm import LogisticSaturation
hierarchical_lam = Prior(
"Gamma",
alpha=Prior("HalfNormal"),
beta=Prior("HalfNormal"),
dims="channel",
)
priors = {
"lam": hierarchical_lam,
"beta": Prior("HalfNormal", dims="channel"),
}
saturation = LogisticSaturation(priors=priors)
Functions
|
Get a saturation function from a dictionary. |
Classes
|
Wrapper around Hill saturation function. |
|
Wrapper around Hill saturation sigmoid function. |
|
Wrapper around inverse scaled logistic saturation function. |
|
Wrapper around logistic saturation function. |
|
Wrapper around Michaelis-Menten saturation function. |
|
Wrapper around linear saturation function. |
|
Wrapper around Root saturation function. |
|
Subclass for all saturation transformations. |
|
Wrapper around tanh saturation function. |
|
Wrapper around tanh saturation function. |