TanhSaturationBaselined#
- class pymc_marketing.mmm.components.saturation.TanhSaturationBaselined(priors=None, prefix=None)[source]#
Wrapper around tanh saturation function.
Multiplies
pymc_marketing.mmm.transformers.tanh_saturation_baselined()by an extra scaling parameterbetaso the response can reach an asymptote other than the gain-implied one.- Parameters:
- x0
tensor Reference point on the input scale, as in
tanh_saturation_baselined(). Default prior:Prior("HalfNormal", sigma=1).- gain
tensor Value of the curve at
x0divided byx0(the ROAS at the baseline). Default prior:Prior("HalfNormal", sigma=1).- r
tensor Overspend fraction, the ratio of the response at
x0to the saturation level. Default prior:Prior("HalfNormal", sigma=1).- beta
tensor Scaling factor applied to the baselined-tanh response (multiplies the gain-implied asymptote
gain * x0 / r). Default prior:Prior("HalfNormal", sigma=1).- .. plot::
- context:
close-figs
import matplotlib.pyplot as plt import numpy as np from pymc_marketing.mmm import TanhSaturationBaselined
rng = np.random.default_rng(0)
adstock = TanhSaturationBaselined() prior = adstock.sample_prior(random_seed=rng) curve = adstock.sample_curve(prior) adstock.plot_curve(curve, random_seed=rng) plt.show()
- x0
Methods
TanhSaturationBaselined.__init__([priors, ...])TanhSaturationBaselined.apply(x, *[, dims, ...])Call within a model context.
Reconstruct a saturation transformation from a dict.
TanhSaturationBaselined.function(x, x0, ...)Tanh saturation function.
TanhSaturationBaselined.plot_curve(curve[, ...])Plot curve HDI and samples.
Plot the HDI of the curve.
Plot samples from the curve.
Sample the curve of the saturation transformation given parameters.
TanhSaturationBaselined.sample_prior([coords])Sample the priors for the transformation.
Set the dims for all priors.
TanhSaturationBaselined.to_dict([_orig])Convert the transformation to a dictionary.
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.