The optimized budget allocation.
meridian.analysis.optimizer.OptimizationResults(
analyzer: meridian.analysis.analyzer.Analyzer,
spend_ratio: np.ndarray,
spend_bounds: tuple[np.ndarray, np.ndarray],
_nonoptimized_data: xr.Dataset,
_nonoptimized_data_with_optimal_freq: xr.Dataset,
_optimized_data: xr.Dataset,
_optimization_grid: meridian.analysis.optimizer.OptimizationGrid,
meridian: (model.Meridian | None) = None,
new_data: (meridian.analysis.DataTensors | None) = None
)
This is a dataclass object containing datasets output from BudgetOptimizer.
The performance metrics (data variables) are: spend, percentage of spend, ROI,
mROI, incremental outcome, CPIK, and effectiveness.
Attributes |
meridian
|
The fitted Meridian model that was used to create this budget
allocation.
|
analyzer
|
The analyzer bound to the model above.
|
spend_ratio
|
The spend ratio used to scale the non-optimized performance
metrics to the optimized performance metrics.
|
spend_bounds
|
The spend bounds used to scale the non-optimized performance
metrics to the optimized performance metrics.
|
nonoptimized_data
|
Performance metrics under the non-optimized budget. For
R&F channels, the non-optimized frequency is used.
|
nonoptimized_data_with_optimal_freq
|
Performance metrics under the
non-optimized budget. For R&F channels, the optimal frequency is used if
frequency was optimized.
|
optimized_data
|
Performance metrics under the optimized budget. For R&F
channels, the optimal frequency is used if frequency was optimized.
|
optimization_grid
|
The grid information used for optimization.
|
new_data
|
The optional DataTensors container that was used to create this
budget allocation.
|
template_env
|
A shared template environment bound to this optimized budget.
|
Methods
get_response_curves
View source
get_response_curves() -> xr.Dataset
Calculates response curves, per budget optimization scenario.
This method is a wrapper for Analyzer.response_curves(), that sets the
following arguments to be consistent with the budget optimization scenario
specified in BudgetOptimizer.optimize() call that returned this result.
In particular:
spend_multiplier matches the discrete optimization grid, considering
the grid step size and any channel-level constraint bounds.
selected_times, by_reach, and use_optimal_frequency match the
values set in BudgetOptimizer.optimize().
output_optimization_summary
View source
output_optimization_summary(
filename: str, filepath: str, currency: (str | None) = None
)
Generates and saves the HTML optimization summary output.
| Args |
filename
|
The filename for the output summary.
|
filepath
|
The directory path to save the output summary.
|
currency
|
(Deprecated) The currency symbol to use for formatting monetary
values. If None, defaults to resolving from the model's
input_data.currency_code (falling back to
constants.DEFAULT_CURRENCY_SYMBOL).
|
plot_budget_allocation
View source
plot_budget_allocation(
optimized: bool = True
) -> alt.Chart
Plots a pie chart showing the spend allocated for each channel.
| Args |
optimized
|
If True, shows the optimized spend. If False, shows the
non-optimized spend.
|
| Returns |
|
An Altair pie chart showing the spend by channel.
|
plot_incremental_outcome_delta
View source
plot_incremental_outcome_delta(
*, is_vertical: bool = True
) -> alt.Chart
Plots a waterfall chart showing the change in incremental outcome.
| Args |
is_vertical
|
If True, the plot has a vertical orientation. If False,
it has a horizontal orientation. Defaults to True.
|
| Returns |
|
An Altair chart object representing the waterfall chart of incremental
outcome changes.
|
plot_response_curves
View source
plot_response_curves(
n_top_channels: (int | None) = None
) -> alt.Chart
Plots the response curves, with spend constraints, for each channel.
| Args |
n_top_channels
|
Optional number of top channels by spend to include. By
default, all channels are included.
|
| Returns |
|
An Altair plot showing the response curves with optimization details.
|
plot_spend_delta
View source
plot_spend_delta(
currency: (str | None) = None, *, is_vertical: bool = True
) -> alt.Chart
Plots a bar chart showing the optimized change in spend per channel.
| Args |
currency
|
(Deprecated) The currency symbol to use for the quantitative
axis. If None, defaults to resolving from the model's
input_data.currency_code (falling back to
constants.DEFAULT_CURRENCY_SYMBOL).
|
is_vertical
|
If True, the plot has a vertical orientation. If False,
it has a horizontal orientation. Defaults to True.
|
| Returns |
|
An Altair bar chart showing the optimized change in spend per channel.
|
__eq__
__eq__(
other
)
Return self==value.
Class Variables |
|
meridian
|
None
|
|
new_data
|
None
|