MMM.allocate_budget_to_maximize_response#

MMM.allocate_budget_to_maximize_response(budget, time_granularity, num_periods, budget_bounds=None, custom_constraints=None, quantile=0.5, noise_level=0.01)[source]#

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

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.

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_boundsdict[str, list[Any]], optional

A dictionary specifying the lower and upper bounds for the budget allocation for each channel. If None, no bounds are applied.

custom_constraintsdict[str, float], optional

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

quantilefloat, optional

The quantile to use for recovering transformation parameters. Default is 0.5.

Returns:
az.InferenceData

The posterior predictive samples generated from the synthetic dataset.

Raises:
ValueError

If the time granularity is not supported.