lightweight_mmm
lightweight_mmm copied to clipboard
Ambiguitiy in `optimal_allocation_per_time_unit` argument of `plot_response_curve`
I think I finally figured it out with trial-and-error, but confirmation from people in the know would be great. Then if appropriate/feasible, I can contribute documentation.
The question is: after obtaining an optimized budget, how should I calculate optimal_allocation_per_timeunit
for plot_response_curve
? It is important to specify this argument, so that we get an intuitive, visual idea of how budgets should be shifted.
Following exactly the example notebook in this repo,
- I am allocating across 20 time periods and 7 media channels;
-
optimal_budget_allocation
is an array generated from optimization routines; it is of length 7 i.e. the number of media channels, and it sums up to about the budget I specified for the optimizer. -
optimal_allocation_per_timeunit
is thereforemedia_scaler.transform(optimal_budget_allocation) / 20
, wheremedia_scaler
is theCustomScaler
object I trained to transform media variables.
^Is what I did correct? I tried several other things before, such as giving the plotting function optimal_budget_allocation
directly, dividing that by 20 etc. It is simply not clear that I am supposed (?) to use media_scaler
.
FYI, the documentation currently says the following about optimal_allocation_per_timeunit
.
If ‘ optimal_allocation_per_timeunit is given it uses it to add markers based on historic average spend and the given optimal one on each of the individual subplots.
optimal_allocation_per_timeunit – Optimal allocation per time unit per media channel. This can be obtained by running the optimization provided by LightweightMMM.
I think you want optimal_allocation_per_timeunit to be media_scaler.transform(optimal_budget_allocation)/n_time_periods, but I agree this is unclear and we'll try to improve this workflow. Thanks for flagging this!