batched_convolution#

pymc_marketing.mmm.transformers.batched_convolution(x, w, axis=0, mode=ConvMode.After)[source]#

Apply a 1D convolution in a vectorized way across multiple batch dimensions.

(Source code, png, hires.png, pdf)

../../_images/pymc_marketing-mmm-transformers-batched_convolution-1.png
Parameters:
xtensor_like

The array to convolve.

wtensor_like

The weight of the convolution. The last axis of w determines the number of steps to use in the convolution.

axisint

The axis of x along witch to apply the convolution

modeConvMode, optional

The convolution mode determines how the convolution is applied at the boundaries of the input signal, denoted as “x.” The default mode is ConvMode.After.

  • ConvMode.After: Applies the convolution with the “Adstock” effect, resulting in a trailing decay effect.

  • ConvMode.Before: Applies the convolution with the “Excitement” effect, creating a leading effect

    similar to the wow factor.

  • ConvMode.Overlap: Applies the convolution with both “Pull-Forward” and “Pull-Backward” effects,

    where the effect overlaps with both preceding and succeeding elements.

Returns:
ytensor_like

The result of convolving x with w along the desired axis. The shape of the result will match the shape of x up to broadcasting with w. The convolved axis will show the results of left padding zeros to x while applying the convolutions.