Skip to content

Commit

Permalink
Bump 1.0.4
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 732156639
  • Loading branch information
santoso-wijaya authored and The Meridian Authors committed Feb 28, 2025
1 parent 4521db1 commit 10bf9cf
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 25 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ To release a new version (e.g. from `1.0.0` -> `2.0.0`):

## [Unreleased]

## [1.0.4] - 2025-02-28

* Fix a divide-by-zero error in spend ratio calculation when historical spend is
zero, preventing a `ValueError` in `output_optimization_summary`.
* Add `non_media_baseline_values` argument to `MediaSummary` visualizations.
Expand Down Expand Up @@ -203,4 +205,5 @@ To release a new version (e.g. from `1.0.0` -> `2.0.0`):
[1.0.1]: https://github.com/google/meridian/releases/tag/v1.0.1
[1.0.2]: https://github.com/google/meridian/releases/tag/v1.0.2
[1.0.3]: https://github.com/google/meridian/releases/tag/v1.0.3
[Unreleased]: https://github.com/google/meridian/compare/v1.0.3...HEAD
[1.0.4]: https://github.com/google/meridian/releases/tag/v1.0.4
[Unreleased]: https://github.com/google/meridian/compare/v1.0.4...HEAD
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ To cite this repository:
author = {Google Meridian Marketing Mix Modeling Team},
title = {Meridian: Marketing Mix Modeling},
url = {https://github.com/google/meridian},
version = {1.0.3},
version = {1.0.4},
year = {2025},
}
```
2 changes: 1 addition & 1 deletion meridian/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

"""Meridian API."""

__version__ = "1.0.3"
__version__ = "1.0.4"


from meridian import analysis
Expand Down
45 changes: 24 additions & 21 deletions meridian/analysis/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -929,30 +929,33 @@ def optimize(
specify either `target_roi` or `target_mroi`.
budget: Number indicating the total budget for the fixed budget scenario.
Defaults to the historical budget.
pct_of_spend: Numeric list of size `n_total_channels` containing the
pct_of_spend: Numeric list of size `n_paid_channels` containing the
percentage allocation for spend for all media and RF channels. The order
must match `InputData.media` with values between 0-1, summing to 1. By
default, the historical allocation is used. Budget and allocation are
used in conjunction to determine the non-optimized media-level spend,
which is used to calculate the non-optimized performance metrics (for
example, ROI) and construct the feasible range of media-level spend with
the spend constraints. Consider using
`InputData.get_paid_channels_argument_builder()` to construct the
argument here.
spend_constraint_lower: Numeric list of size `n_total_channels` or float
must match `(InputData.media + InputData.reach)` with values between
0-1, summing to 1. By default, the historical allocation is used. Budget
and allocation are used in conjunction to determine the non-optimized
media-level spend, which is used to calculate the non-optimized
performance metrics (for example, ROI) and construct the feasible range
of media-level spend with the spend constraints. Consider using
`InputData.get_paid_channels_argument_builder()` to construct this
argument.
spend_constraint_lower: Numeric list of size `n_paid_channels` or float
(same constraint for all channels) indicating the lower bound of
media-level spend. The lower bound of media-level spend is `(1 -
spend_constraint_lower) * budget * allocation)`. The value must be
between 0-1. Defaults to `0.3` for fixed budget and `1` for flexible.
Consider using `InputData.get_paid_channels_argument_builder()` to
construct the argument here.
spend_constraint_upper: Numeric list of size `n_total_channels` or float
media-level spend. If given as a channel-indexed array, the order must
match `(InputData.media + InputData.reach)`. The lower bound of
media-level spend is `(1 - spend_constraint_lower) * budget *
allocation)`. The value must be between 0-1. Defaults to `0.3` for fixed
budget and `1` for flexible. Consider using
`InputData.get_paid_channels_argument_builder()` to construct this
argument.
spend_constraint_upper: Numeric list of size `n_paid_channels` or float
(same constraint for all channels) indicating the upper bound of
media-level spend. The upper bound of media-level spend is `(1 +
spend_constraint_upper) * budget * allocation)`. Defaults to `0.3` for
fixed budget and `1` for flexible. Consider using
`InputData.get_paid_channels_argument_builder()` to construct the
argument here.
media-level spend. If given as a channel-indexed array, the order must
match `(InputData.media + InputData.reach)`. The upper bound of
media-level spend is `(1 + spend_constraint_upper) * budget *
allocation)`. Defaults to `0.3` for fixed budget and `1` for flexible.
Consider using `InputData.get_paid_channels_argument_builder()` to
construct this argument.
target_roi: Float indicating the target ROI constraint. Only used for
flexible budget scenarios. The budget is constrained to when the ROI of
the total spend hits `target_roi`.
Expand Down
14 changes: 13 additions & 1 deletion meridian/analysis/optimizer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1867,8 +1867,20 @@ def test_budget_data_with_specified_pct_of_spend(
)
expected_pct_of_spend = [0.1, 0.2, 0.3, 0.3, 0.1]

idata = self.budget_optimizer_media_and_rf._meridian.input_data
paid_channels = list(
idata.get_all_paid_channels()
)
pct_of_spend = idata.get_paid_channels_argument_builder()(**{
paid_channels[0]: 0.1,
paid_channels[1]: 0.2,
paid_channels[2]: 0.3,
paid_channels[3]: 0.3,
paid_channels[4]: 0.1,
})

optimization_results = self.budget_optimizer_media_and_rf.optimize(
pct_of_spend=expected_pct_of_spend, fixed_budget=True
pct_of_spend=pct_of_spend, fixed_budget=True
)

actual_spend = optimization_results.nonoptimized_data.spend
Expand Down

0 comments on commit 10bf9cf

Please sign in to comment.