Provides core, stateless mathematical functions for Meridian MMM.
meridian.model.equations.ModelEquations(
model_context: meridian.model.context.ModelContext
)
Methods
View source
adstock_hill_media(
media: meridian.backend.Tensor,
alpha: meridian.backend.Tensor,
ec: meridian.backend.Tensor,
slope: meridian.backend.Tensor,
decay_functions: (str | Sequence[str]) = constants.GEOMETRIC_DECAY,
n_times_output: (int | None) = None
) -> meridian.backend.Tensor
Transforms media or using Adstock and Hill functions in the desired order.
| Args |
media
|
Tensor of dimensions (n_geos, n_media_times, n_media_channels)
containing non-negative media execution values. Typically this is
impressions, but it can be any metric, such as media_spend. Clicks are
often used for paid search ads.
|
alpha
|
Uniform distribution for Adstock and Hill calculations.
|
ec
|
Shifted half-normal distribution for Adstock and Hill calculations.
|
slope
|
Deterministic distribution for Adstock and Hill calculations.
|
decay_functions
|
String or sequence of strings denoting the adstock decay
function(s) for each channel. Default: 'geometric'.
|
n_times_output
|
Number of time periods to output. This argument is
optional when the number of time periods in media equals
n_media_times, in which case n_times_output defaults to n_times.
|
| Returns |
Tensor with dimensions [..., n_geos, n_times, n_media_channels]
representing Adstock and Hill-transformed media.
|
adstock_hill_rf
View source
adstock_hill_rf(
reach: meridian.backend.Tensor,
frequency: meridian.backend.Tensor,
alpha: meridian.backend.Tensor,
ec: meridian.backend.Tensor,
slope: meridian.backend.Tensor,
decay_functions: (str | Sequence[str]) = constants.GEOMETRIC_DECAY,
n_times_output: (int | None) = None
) -> meridian.backend.Tensor
Transforms reach and frequency (RF) using Hill and Adstock functions.
| Args |
reach
|
Tensor of dimensions (n_geos, n_media_times, n_rf_channels)
containing non-negative media for reach.
|
frequency
|
Tensor of dimensions (n_geos, n_media_times, n_rf_channels)
containing non-negative media for frequency.
|
alpha
|
Uniform distribution for Adstock and Hill calculations.
|
ec
|
Shifted half-normal distribution for Adstock and Hill calculations.
|
slope
|
Deterministic distribution for Adstock and Hill calculations.
|
decay_functions
|
String or sequence of strings denoting the adstock decay
function(s) for each channel. Default: 'geometric'.
|
n_times_output
|
Number of time periods to output. This argument is
optional when the number of time periods in reach equals
n_media_times, in which case n_times_output defaults to n_times.
|
| Returns |
Tensor with dimensions [..., n_geos, n_times, n_rf_channels]
representing Hill and Adstock-transformed RF.
|
calculate_beta_x
View source
calculate_beta_x(
is_non_media: bool,
incremental_outcome_x: meridian.backend.Tensor,
linear_predictor_counterfactual_difference: meridian.backend.Tensor,
eta_x: meridian.backend.Tensor,
beta_gx_dev: meridian.backend.Tensor
) -> meridian.backend.Tensor
View source
compute_non_media_treatments_baseline(
non_media_baseline_values: (Sequence[str | float] | None) = None
) -> meridian.backend.Tensor
View source
linear_predictor_counterfactual_difference_media(
media_transformed: meridian.backend.Tensor,
alpha_m: meridian.backend.Tensor,
ec_m: meridian.backend.Tensor,
slope_m: meridian.backend.Tensor
) -> meridian.backend.Tensor
linear_predictor_counterfactual_difference_rf
View source
linear_predictor_counterfactual_difference_rf(
rf_transformed: meridian.backend.Tensor,
alpha_rf: meridian.backend.Tensor,
ec_rf: meridian.backend.Tensor,
slope_rf: meridian.backend.Tensor
) -> meridian.backend.Tensor