pymc-marketing
pymc-marketing copied to clipboard
Scale spend data to improve budget allocation efficacy
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
- [x] Checked that the pre-commit linting/style checks pass
- [ ] Included tests that prove the fix is effective or that the new feature works
- [ ] Added necessary documentation (docstrings and/or example notebooks)
- [ ] If you are a pro: each commit corresponds to a relevant logical change
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/