Tensor of alpha parameters taking values in [0, 1] with
dimensions [..., n_media_channels]. Batch dimensions (...) are
optional. Note that alpha = 0 is allowed, so it is possible to put a
point mass prior at zero (effectively no Adstock).
max_lag
Integer indicating the maximum number of lag periods (≥ 0) to
include in the Adstock calculation.
n_times_output
Integer indicating the number of time periods to include
in the output tensor. Cannot exceed the number of time periods of the
media argument, for example, media.shape[-2]. The output time periods
correspond to the most recent time periods of the media argument. For
example, media[..., -n_times_output:, :] represents the media
execution of the output weeks.
decay_functions
String or list of strings indicating the decay
function(s) to use for the Adstock calculation for each channel.
Default is geometric decay for all channels.
Computes the Adstock transformation of a given media tensor.
For geo g, time period t, and media channel m, Adstock is calculated
as adstock_{g,t,m} = sum_{i=0}^max_lag media_{g,t-i,m} alpha^i.
Args
media
Tensor of media values with dimensions [..., n_geos,
n_media_times, n_media_channels]. Batch dimensions (...) are
optional, but if batch dimensions are included, they must match the
batch dimensions of alpha. Media is not required to have batch
dimensions even if alpha contains batch dimensions.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-05 UTC."],[],["The `AdstockTransformer` computes the Adstock transformation of media data. It takes `alpha` (decay rate), `max_lag` (lag periods), and `n_times_output` (output time periods) as input. The `forward` method calculates Adstock for each geo, time period, and media channel using the formula `sum_{i=0}^max_lag media_{g,t-i,m} alpha^i`. Input `media` is a tensor of media values. The output is a tensor representing Adstock-transformed media with specified dimensions.\n"],null,[]]