EvaluationWindows.build_scenarios#
- EvaluationWindows.build_scenarios(*, baseline_array, counterfactual_spend_factor, dtype, channel_axis, n_channels, estimand)[source]#
Build the perturbed spend arrays that have to be evaluated.
Two scenario layouts are produced, and which one applies is the whole difference between a plain MMM and a mediated one:
channel_axis is None– separable. One all-channels perturbation per period. Because \(v_{t,c}\) depends on channel c’s spend alone, column m of that single scenario already is channel m’s counterfactual, so every channel key points at the same row and the joint scenario costs nothing extra.channel_axisgiven – per channel. One perturbation per (period, channel), because a mediated effect mixes channels before reaching the response and no per-channel column survives to be read off. Asked for the joint estimand this collapses back to one perturbation per period: the per-channel rows would otherwise be built, evaluated and never read.
- Parameters:
- baseline_array
np.ndarray Actual channel spend, shape
(n_dates, *extra_shape).- counterfactual_spend_factor
float Multiplicative factor for counterfactual spend.
- dtype
str NumPy dtype for the output array.
- channel_axis
intorNone Axis of
channelwithinbaseline_array’s non-date axes, orNoneto perturb all channels at once. Panel models laychannel_dataout as(date, *custom_dims, channel), so this is not always zero.- n_channels
int Number of channels.
- estimand{“per_channel”, “joint”}
Which scenarios are going to be read. Only those get built: the difference is a factor of
n_channelsin every downstream cost for a mediated model asked for the joint number.
- baseline_array
- Returns:
CounterfactualScenariosPerturbed spend plus the bookkeeping needed to find the row for a given
_ScenarioKeyand to broadcast per-period arrays over scenarios.