TanhSaturation#
- class pymc_marketing.mmm.components.saturation.TanhSaturation(priors=None, prefix=None)[source]#
Wrapper around tanh saturation function.
Calls
pymc_marketing.mmm.transformers.tanh_saturation()directly. The saturation level is already exposed by the underlying function asb, so no extra scaling parameter is added at this layer.- Parameters:
- b
tensor Saturation point, the asymptote that the response approaches. Default prior:
Prior("HalfNormal", sigma=1).- c
tensor Initial cost per user; larger values give a less efficient channel. Must be non-zero. Default prior:
Prior("HalfNormal", sigma=1).- .. plot::
- context:
close-figs
import matplotlib.pyplot as plt import numpy as np from pymc_marketing.mmm import TanhSaturation
rng = np.random.default_rng(0)
adstock = TanhSaturation() prior = adstock.sample_prior(random_seed=rng) curve = adstock.sample_curve(prior) adstock.plot_curve(curve, random_seed=rng) plt.show()
- b
Methods
TanhSaturation.__init__([priors, prefix])TanhSaturation.apply(x, *[, core_dim, idx])Call within a model context.
TanhSaturation.from_dict(data)Reconstruct a transformation from a dict.
TanhSaturation.function(x, b, c, *[, dim])Tanh saturation function.
TanhSaturation.plot_curve(curve[, ...])Plot curve HDI and samples.
TanhSaturation.plot_curve_hdi(curve[, ...])Plot the HDI of the curve.
TanhSaturation.plot_curve_samples(curve[, ...])Plot samples from the curve.
TanhSaturation.sample_curve([parameters, ...])Sample the curve of the saturation transformation given parameters.
TanhSaturation.sample_prior([coords])Sample the priors for the transformation.
Set the dims for all priors.
TanhSaturation.to_dict([_orig])Convert the transformation to a dictionary.
TanhSaturation.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
Get the combined dims for all the parameters.
Get the priors for the function.
Mapping from variable name to prior for the model.
Get the priors for the function.
Whether the saturation must receive raw (unscaled) channel inputs.
Mapping from parameter name to variable name in the model.