PeriodWindow#
- class pymc_marketing.mmm.counterfactual.PeriodWindow(start, end, in_window, actual_dates, in_eval, eval_dates)[source]#
The stretch of fitted dates one period is evaluated over.
Two nested date ranges, and the distinction between them is load-bearing. The window is what the graph is handed, wide enough on both sides that the perturbation’s whole effect is computed correctly. The evaluation dates are the subset whose differences are summed into the increment. Both are recorded here, in the two forms the rest of the code needs them in – a mask over the full date axis, for slicing a full-axis baseline, and the dates themselves, for labelling coordinates – so that no caller has to recompute either from
l_maxand a frequency offset and hope it lands on the same answer.- Parameters:
- start, end
pd.Timestamp Bounds of the period itself – the dates the counterfactual factor is applied to, as opposed to the wider window it is evaluated over.
- in_window
np.ndarray Boolean mask over the full date axis selecting the window’s dates.
- actual_dates
pd.DatetimeIndex Those dates, in order.
- in_eval
np.ndarray Boolean mask over the full date axis selecting the dates that enter the sum. A subset of
in_window, by construction.- eval_dates
pd.DatetimeIndex Those dates, in order.
- start, end
Methods
PeriodWindow.__init__(start, end, in_window, ...)PeriodWindow.build(*, start, end, dates, ...)Derive both date ranges from the window mask and the carry-out end.
PeriodWindow.eval_mask(max_window)Positions in the padded window that enter the sum.
PeriodWindow.offsets_within(first, last)Positions inside the window of the dates in
[first, last].Attributes
n_actualHow many fitted dates fall in the window.
startendin_windowactual_datesin_evaleval_dates