Transform#
- class pymc_marketing.terms.Transform(inner, func)[source]#
Apply a pytensor function to a term’s output.
Delegates coordinates, data registration, and data updating to the inner expression. Covers link functions and arbitrary transformations without a separate link system.
- Parameters:
- inner
Any Inner expression accepted by
build_param(ModelTerm,Sum,float,Prior, etc.).- func
Callable A pytensor function applied to
build_param(inner). E.g.,pytensor.xtensor.math.exp,ptx.math.sigmoid.
- inner
Examples
import pytensor.xtensor as ptx sigma = Transform(Intercept(name="sigma"), func=ptx.math.exp)
innermay be any expression, including customModelTermsubclasses and composed trees:from pymc_extras.prior import Prior from pymc_marketing.terms import Dot, Transform effect = Transform( Dot(var_name="x", prior=Prior("Normal", dims="feature")), func=ptx.math.softplus, )
Methods
Transform.__init__(inner, func)Add coordinates to the model during
register_data.Build
func(build_param(inner)).Transform.from_dict(data)Reconstruct a transform from its serialized form.
Collect coordinates from the inner expression.
Register shared data for the inner expression.
Transform.set_data(ds[, model])Update shared data for the inner expression.
Transform.to_dict([_orig])Attributes