PlanEvaluation#
- class pymc_marketing.mmm.budget_optimizer.PlanEvaluation(objective, objective_gradient, constraint_residuals=None)[source]#
The compiled objective and its gradient at one labelled plan.
Returned by
BudgetOptimizer.evaluate_plan(). Both sign conventions are offered because both are wanted and confusing them is silent: the optimizer minimisesobjective = -utility, soobjectiveis what compares withscipy_result.fun, whileutilityis what compares with a response.- Attributes:
- objective
float The objective at the plan, on the minimiser’s scale (the negated utility). Equal to
result.scipy_result.funwhen the plan is the solution of that run.- objective_gradient
dict[str,xarray.DataArray] Derivative of
objectivewith respect to every decision cell, keyed by decision-variable name and labelled with that variable’s own dims and coords – the same layoutunpack()produces. Cells outside the optimization mask are reported as0.0because they are not decision variables, not because the response is insensitive to them;optimizer.budgets_to_optimizesays which is which.- constraint_residuals
dict[str,ConstraintResidual] orNone Value of every registered constraint at the plan, keyed by
Constraintkey, whenBudgetOptimizer.evaluate_plan()was called with atotal_budget;Noneotherwise. Seefeasible().
- objective
Notes
Gradient units follow the decision variable: for media this is response per unit of per-period spend sustained over the whole window, including the carry-over tail. Divide by the number of periods for a per-dollar figure. A lever’s entry is in that lever’s own units.
Methods
PlanEvaluation.__init__(objective, ...[, ...])PlanEvaluation.feasible([atol])Whether every registered constraint holds at the plan.
Attributes
The utility at the plan:
-objective, the quantity being maximised.Derivative of the utility per decision cell:
-objective_gradient.