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_unit and stores it in idata.constant_data. This precomputed spend is used by get_channel_spend() for ROAS calculations.

Parameters:
cost_per_unitpd.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).

Raises:
RuntimeError

If model has not been fitted yet (no idata available).

ValueError

If date/dim values don’t match the fitted data.