CounterfactualEvaluator.evaluate_counterfactual#
- CounterfactualEvaluator.evaluate_counterfactual(scenarios, *, windows, batch_size=None)[source]#
Evaluate every node on all counterfactual scenarios.
Auxiliary date-indexed inputs are cut here rather than by the caller, then broadcast from per-period to per-scenario through
CounterfactualScenarios.period_index.Scenarios are evaluated in batches. The graph’s intermediates are what makes the difference: an adstock of length
l_maxmaterializes a lagged copy per lag, so a batch’s working set is a multiple of its output, and a mediated per-channel run over many periods can ask for far more of that at once than it has to. Batches are concatenated in scenario order, soCounterfactualScenarios.rowskeeps addressing the same results.- Parameters:
- scenarios
CounterfactualScenarios Perturbed spend and its scenario bookkeeping.
- windows
EvaluationWindows The windows the scenarios were built for.
- batch_size
int, optional Scenarios per evaluation. Defaults to whatever keeps a batch’s outputs under
MAX_BATCH_ELEMENTS, and is exposed so a test can pin one batch against many.
- scenarios
- Returns:
dictPer response variable, an array of shape
(n_scenarios, n_samples, max_window, *non_date_dims).