MMM.budget_optimizer#

MMM.budget_optimizer(start_date, end_date, *, budgets_to_optimize=None, cost_per_unit=None, compile_kwargs=None, **kwargs)[source]#

Create a BudgetOptimizer for a future window.

This is the recommended entry point for budget optimization with the multidimensional MMM. It handles building the optimization model, computing num_periods and pulling adstock_periods from the fitted adstock. When budgets_to_optimize is not supplied, BudgetOptimizer auto-detects the optimizable cells from the posterior.

Parameters:
start_datestr or pd.Timestamp

First date of the optimization window (inclusive).

end_datestr or pd.Timestamp

Last date of the optimization window (inclusive).

budgets_to_optimizexr.DataArray or None, optional

Boolean mask defining which budget cells to optimize. Passed straight through to BudgetOptimizer; when None the optimizer optimizes every cell with a non-zero mean channel_contribution in the posterior.

cost_per_unitpd.DataFrame or xr.DataArray or None, optional

Cost-per-unit conversion factors for non-monetary channels.

compile_kwargsdict or None, optional

Extra keyword arguments for PyTensor’s function().

**kwargs

Additional arguments forwarded to BudgetOptimizer.

Returns:
BudgetOptimizer

A configured optimizer ready for BudgetOptimizer.allocate_budget().