Class to compute the Adstock transformation of media.
Inherits From: AdstockHillTransformer
meridian
.
model
.
adstock_hill
.
AdstockTransformer
(
alpha
:
meridian
.
backend
.
Tensor
,
max_lag
:
int
,
n_times_output
:
int
,
decay_functions
:
(
str
|
Sequence
[
str
])
=
constants
.
GEOMETRIC_DECAY
)
Args
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).Integer indicating the maximum number of lag periods (≥
0
) to
include in the Adstock calculation.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.Methods
forward
forward
(
media
:
meridian
.
backend
.
Tensor
)
->
meridian
.
backend
.
Tensor
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.
Returns
Tensor with dimensions
[..., n_geos, n_times_output, n_media_channels]
representing Adstock transformed media.


