pymc-labs / pymc-marketing

Bayesian marketing toolbox in PyMC. Media Mix (MMM), customer lifetime value (CLV), buy-till-you-die (BTYD) models and more.
https://www.pymc-marketing.io/
Apache License 2.0
697 stars 194 forks source link

Custom Optimization constraints #475

Open Wajiharfaoui opened 10 months ago

Wajiharfaoui commented 10 months ago

Hello, is there a way to include constraints, other than budget bounds in the budget optimization ? like for example including the carbon emission ... Thank you

nialloulton commented 9 months ago

Ah I think I understand the question. Essentially allocating a penalty of CO2 emissions by channel. Then when optimizing, the model ensures you don't exceed a carbon emissions constraint?

twiecki commented 9 months ago

@Wajiharfaoui There's two ways to do this:

  1. as a hard bound (CO2 emissions can not be larger than X)
  2. as a penalty (there's a penalty to choosing a solution with lots of CO2).

I looked a bit at the code and it doesn't seem like it allows for this flexiblity. You would have to change the objective function https://github.com/pymc-labs/pymc-marketing/blob/main/pymc_marketing/mmm/budget_optimizer.py#L74. Perhaps you can monkey-patch your own. Ultimately it would be better if this was an argument to the budget optimizer.

CC @carlosagostini