MediaVariable.from_model#
- classmethod MediaVariable.from_model(model, name, *, num_periods, adstock_periods, mask=None, carry_in_values=None, carry_in_periods=0, scales=1.0, date_dim='date', **kwargs)[source]#
Build a monetary variable by reading a named node’s dims off a model.
The media budgets are one instance of a monetary decision; a lower-funnel spend, or the reach an impression budget buys, is another. What distinguishes them is which node they substitute and over which dims they are decided, and both already live in the model, so callers name the node and this reads the rest.
- Parameters:
- model
Model The model holding the node.
- name
str Name of the monetary node to optimize. Must carry named dims, including date_dim.
- num_periods, adstock_periods
int Decision and carry-over period counts for the window.
- mask
DataArrayorNone Which cells to optimize, over the node’s non-date dims. Defaults to all of them.
- carry_in_values
np.ndarrayorNone Spend already made before the window, one leading period per row.
- carry_in_periods
int Read that many leading periods off the node itself when carry_in_values is not given. Read after the name is validated, so a typo is reported as a typo.
- scales
floatornp.ndarray Scale factors converting monetary amounts into the node’s units.
- date_dim
str The model’s date dimension, which the node must vary over.
- **kwargs
Passed through to the constructor.
- model
- Returns:
MediaVariableA monetary variable over
name.
- Raises:
ValueErrorIf
namehas no named dims, or does not vary over date_dim.