pymc-marketing icon indicating copy to clipboard operation
pymc-marketing copied to clipboard

Scale spend data to improve budget allocation efficacy

Open MobiusLooper opened this issue 6 months ago • 8 comments

Description

This change adds scaling to the budget, bounds, and initial guess inside the BudgetOptimizer before handing the budget to the minimize function. It then unscales the data inside the objective function, and again unscales them when passing them back to the MMM at the end of the allocate_budget method. This is because the new changes from PR933 lead to potentially large values being handed to the SLSQP minimizer, and from what I understand, this optimisation is best suited to well scaled data. On my MMM, the larger scale of input (spend in the $100,000 region) meant the optimizer got stuck in a very flat part of the search space, and effectively regurgitated the equally weighted initial guess as optimal, which it was far from being.

I didn't add any tests because it would require instantiating a fitted MMM with actual parameters, and demonstrating that the output deviating from the initial guess, but given the presumably stochastic nature of the optimisation, that felt like not a very good test anyway. But, I could think of something if necessary.

Related Issue

  • [ ] Closes #
  • [x] Related to #843

Checklist

Modules affected

  • [x] MMM
  • [ ] CLV

Type of change

  • [ ] New feature / enhancement
  • [x] Bug fix
  • [ ] Documentation
  • [ ] Maintenance
  • [ ] Other (please specify):

📚 Documentation preview 📚: https://pymc-marketing--945.org.readthedocs.build/en/945/

MobiusLooper avatar Aug 19 '24 15:08 MobiusLooper