MMM.set_cost_per_unit#
- MMM.set_cost_per_unit(cost_per_unit)[source]#
Set or update cost_per_unit metadata for the fitted model.
Allows post-hoc specification of conversion factors after model fitting. Computes
channel_spend = channel_data * cost_per_unitand stores it inidata.constant_data. This precomputed spend is used byget_channel_spend()for ROAS calculations.- Parameters:
- cost_per_unit
pd.DataFrame Wide-format DataFrame. Rows are
(date, *custom_dims)combinations; columns are channel names with cost values. Not all model channels need to appear; missing channels default to 1.0 (assumed already in spend units).
- cost_per_unit
- Raises:
RuntimeErrorIf model has not been fitted yet (no idata available).
ValueErrorIf date/dim values don’t match the fitted data.