BudgetOptimizer#
- class pymc_marketing.mmm.budget_optimizer.BudgetOptimizer(**data)[source]#
A class for optimizing budget allocation in a marketing mix model.
The goal of this optimization is to maximize the total expected response by allocating the given budget across different marketing channels. The optimization is performed using the Sequential Least Squares Quadratic Programming (SLSQP) method, which is a gradient-based optimization algorithm suitable for solving constrained optimization problems.
For more information on the SLSQP algorithm, refer to the documentation: https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html
- Parameters:
- adstock
AdstockTransformation
The adstock class.
- saturation
SaturationTransformation
The saturation class.
- num_periods
int
The number of time units.
- parameters
dict
A dictionary of parameters for each channel.
- adstock_firstbool, optional
Whether to apply adstock transformation first or saturation transformation first. Default is True.
- adstock
Methods
BudgetOptimizer.__init__
(**data)Create a new model by parsing and validating input data from keyword arguments.
BudgetOptimizer.allocate_budget
(total_budget)Allocate the budget based on the total budget, budget bounds, and custom constraints.
BudgetOptimizer.construct
([_fields_set])BudgetOptimizer.copy
(*[, include, exclude, ...])Returns a copy of the model.
BudgetOptimizer.dict
(*[, include, exclude, ...])BudgetOptimizer.json
(*[, include, exclude, ...])BudgetOptimizer.model_construct
([_fields_set])Creates a new instance of the
Model
class with validated data.BudgetOptimizer.model_copy
(*[, update, deep])Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
BudgetOptimizer.model_dump
(*[, mode, ...])Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
BudgetOptimizer.model_dump_json
(*[, indent, ...])Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON schema for a model class.
Compute the class name for parametrizations of generic classes.
Override this method to perform additional initialization after
__init__
andmodel_construct
.BudgetOptimizer.model_rebuild
(*[, force, ...])Try to rebuild the pydantic-core schema for the model.
BudgetOptimizer.model_validate
(obj, *[, ...])Validate a pydantic model instance.
BudgetOptimizer.model_validate_json
(json_data, *)Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given object with string data against the Pydantic model.
BudgetOptimizer.objective
(budgets)Calculate the total response during a period of time given the budgets.
BudgetOptimizer.parse_file
(path, *[, ...])BudgetOptimizer.parse_raw
(b, *[, ...])BudgetOptimizer.schema
([by_alias, ref_template])BudgetOptimizer.schema_json
(*[, by_alias, ...])BudgetOptimizer.update_forward_refs
(**localns)BudgetOptimizer.validate
(value)Attributes
model_computed_fields
A dictionary of computed field names and their corresponding
ComputedFieldInfo
objects.model_config
Configuration for the model, should be a dictionary conforming to [
ConfigDict
][pydantic.config.ConfigDict].model_extra
Get extra fields set during validation.
model_fields
Metadata about the fields defined on the model, mapping of field names to [
FieldInfo
][pydantic.fields.FieldInfo] objects.model_fields_set
Returns the set of fields that have been explicitly set on this model instance.
adstock
saturation
num_periods
parameters
scales
adstock_first