MMM.allocate_budget_to_maximize_response#

MMM.allocate_budget_to_maximize_response(budget, time_granularity, num_periods, budget_bounds=None, custom_constraints=None, noise_level=0.01, utility_function=<function average_response>, **minimize_kwargs)[source]#

Allocate the given budget to maximize the response over a specified time period.

Deprecated since version 0.1.0: This method is deprecated and will be removed in a future version. Use optimize_budget() instead.

This function optimizes the allocation of a given budget across different channels to maximize the response, considering adstock and saturation effects. It scales the budget and budget bounds, performs the optimization, and generates a synthetic dataset for posterior predictive sampling.

The function first scales the budget and budget bounds using the maximum scale of the channel transformer. It then uses the BudgetOptimizer to allocate the budget, and creates a synthetic dataset based on the optimal allocation. Finally, it performs posterior predictive sampling on the synthetic dataset.

Important: When generating the posterior predicive distribution for the target with the optimized budget, we are setting the control variables to zero! This is done because in many situations we do not have all the control variables in the future (e.g. outlier control, special events).

Parameters:
budgetfloat or int

The total budget to be allocated.

time_granularitystr

The granularity of the time units (num_periods) (e.g., ‘daily’, ‘weekly’, ‘monthly’).

num_periodsfloat

The number of time units over which the budget is to be allocated.

budget_boundsDatArray or dict[str, list[Any]], optional

An xarray DataArray or a dictionary specifying the lower and upper bounds for the budget allocation for each channel. If None, no bounds are applied.

custom_constraintsSequence[dict[str, Any]], optional

Custom constraints for the optimization. If None, no custom constraints are applied.

noise_levelfloat, optional

The level of noise added to the allocation strategy (by default 1%).

utility_functionUtilityFunctionType, optional

The utility function to maximize. Default is the mean of the response distribution.

**minimize_kwargs

Additional arguments to pass to the BudgetOptimizer.

Returns:
az.InferenceData

The posterior predictive samples generated from the synthetic dataset.

Raises:
ValueError

If the time granularity is not supported.

ValueError

If the noise level is not a float.