google-meridian 1.2.0__py3-none-any.whl → 1.2.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {google_meridian-1.2.0.dist-info → google_meridian-1.2.1.dist-info}/METADATA +2 -2
- {google_meridian-1.2.0.dist-info → google_meridian-1.2.1.dist-info}/RECORD +24 -24
- meridian/analysis/analyzer.py +101 -37
- meridian/analysis/optimizer.py +132 -88
- meridian/analysis/summarizer.py +31 -16
- meridian/analysis/visualizer.py +16 -5
- meridian/backend/__init__.py +475 -14
- meridian/backend/config.py +75 -16
- meridian/backend/test_utils.py +87 -1
- meridian/constants.py +14 -9
- meridian/data/input_data.py +7 -2
- meridian/data/test_utils.py +5 -3
- meridian/mlflow/autolog.py +2 -2
- meridian/model/adstock_hill.py +10 -9
- meridian/model/eda/eda_engine.py +440 -11
- meridian/model/knots.py +1 -1
- meridian/model/model_test_data.py +15 -9
- meridian/model/posterior_sampler.py +365 -365
- meridian/model/prior_distribution.py +104 -39
- meridian/model/transformers.py +5 -5
- meridian/version.py +1 -1
- {google_meridian-1.2.0.dist-info → google_meridian-1.2.1.dist-info}/WHEEL +0 -0
- {google_meridian-1.2.0.dist-info → google_meridian-1.2.1.dist-info}/licenses/LICENSE +0 -0
- {google_meridian-1.2.0.dist-info → google_meridian-1.2.1.dist-info}/top_level.txt +0 -0
meridian/analysis/visualizer.py
CHANGED
|
@@ -863,6 +863,7 @@ class MediaEffects:
|
|
|
863
863
|
confidence_level: float = c.DEFAULT_CONFIDENCE_LEVEL,
|
|
864
864
|
selected_times: frozenset[str] | None = None,
|
|
865
865
|
by_reach: bool = True,
|
|
866
|
+
use_kpi: bool = False,
|
|
866
867
|
) -> xr.Dataset:
|
|
867
868
|
"""Dataset holding the calculated response curves data.
|
|
868
869
|
|
|
@@ -886,12 +887,14 @@ class MediaEffects:
|
|
|
886
887
|
by_reach: For the channel w/ reach and frequency, return the response
|
|
887
888
|
curves by reach given fixed frequency if true; return the response
|
|
888
889
|
curves by frequency given fixed reach if false.
|
|
890
|
+
use_kpi: If `True`, calculate the incremental KPI. Otherwise, calculate
|
|
891
|
+
the incremental revenue using the revenue per KPI (if available).
|
|
889
892
|
|
|
890
893
|
Returns:
|
|
891
894
|
A Dataset displaying the response curves data.
|
|
892
895
|
"""
|
|
893
896
|
selected_times_list = list(selected_times) if selected_times else None
|
|
894
|
-
use_kpi = self._meridian.input_data.revenue_per_kpi is None
|
|
897
|
+
use_kpi = use_kpi or self._meridian.input_data.revenue_per_kpi is None
|
|
895
898
|
return self._analyzer.response_curves(
|
|
896
899
|
spend_multipliers=list(np.arange(0, 2.2, c.RESPONSE_CURVE_STEP_SIZE)),
|
|
897
900
|
confidence_level=confidence_level,
|
|
@@ -961,6 +964,7 @@ class MediaEffects:
|
|
|
961
964
|
confidence_level: float = c.DEFAULT_CONFIDENCE_LEVEL,
|
|
962
965
|
selected_times: frozenset[str] | None = None,
|
|
963
966
|
by_reach: bool = True,
|
|
967
|
+
use_kpi: bool = False,
|
|
964
968
|
plot_separately: bool = True,
|
|
965
969
|
include_ci: bool = True,
|
|
966
970
|
num_channels_displayed: int | None = None,
|
|
@@ -986,6 +990,8 @@ class MediaEffects:
|
|
|
986
990
|
by_reach: For the channel w/ reach and frequency, return the response
|
|
987
991
|
curves by reach given fixed frequency if true; return the response
|
|
988
992
|
curves by frequency given fixed reach if false.
|
|
993
|
+
use_kpi: If `True`, calculate the incremental KPI. Otherwise, calculate
|
|
994
|
+
the incremental revenue using the revenue per KPI (if available).
|
|
989
995
|
plot_separately: If `True`, the plots are faceted. If `False`, the plots
|
|
990
996
|
are layered to create one plot with all of the channels.
|
|
991
997
|
include_ci: If `True`, plots the credible interval. Defaults to `True`.
|
|
@@ -1021,11 +1027,13 @@ class MediaEffects:
|
|
|
1021
1027
|
confidence_level=confidence_level,
|
|
1022
1028
|
selected_times=selected_times,
|
|
1023
1029
|
by_reach=by_reach,
|
|
1030
|
+
use_kpi=use_kpi,
|
|
1031
|
+
)
|
|
1032
|
+
y_axis_label = (
|
|
1033
|
+
summary_text.INC_KPI_LABEL
|
|
1034
|
+
if use_kpi or self._meridian.input_data.revenue_per_kpi is None
|
|
1035
|
+
else summary_text.INC_OUTCOME_LABEL
|
|
1024
1036
|
)
|
|
1025
|
-
if self._meridian.input_data.revenue_per_kpi is not None:
|
|
1026
|
-
y_axis_label = summary_text.INC_OUTCOME_LABEL
|
|
1027
|
-
else:
|
|
1028
|
-
y_axis_label = summary_text.INC_KPI_LABEL
|
|
1029
1037
|
base = (
|
|
1030
1038
|
alt.Chart(response_curves_df, width=c.VEGALITE_FACET_DEFAULT_WIDTH)
|
|
1031
1039
|
.transform_calculate(
|
|
@@ -1333,6 +1341,7 @@ class MediaEffects:
|
|
|
1333
1341
|
selected_times: frozenset[str] | None = None,
|
|
1334
1342
|
confidence_level: float = c.DEFAULT_CONFIDENCE_LEVEL,
|
|
1335
1343
|
by_reach: bool = True,
|
|
1344
|
+
use_kpi: bool = False,
|
|
1336
1345
|
) -> pd.DataFrame:
|
|
1337
1346
|
"""Returns DataFrame with top channels by spend for the layered plot.
|
|
1338
1347
|
|
|
@@ -1347,6 +1356,7 @@ class MediaEffects:
|
|
|
1347
1356
|
by_reach: For the channel w/ reach and frequency, return the response
|
|
1348
1357
|
curves by reach given fixed frequency if true; return the response
|
|
1349
1358
|
curves by frequency given fixed reach if false.
|
|
1359
|
+
use_kpi: If `True`, use KPI instead of revenue.
|
|
1350
1360
|
|
|
1351
1361
|
Returns:
|
|
1352
1362
|
A DataFrame containing the top chosen channels
|
|
@@ -1357,6 +1367,7 @@ class MediaEffects:
|
|
|
1357
1367
|
confidence_level=confidence_level,
|
|
1358
1368
|
selected_times=selected_times,
|
|
1359
1369
|
by_reach=by_reach,
|
|
1370
|
+
use_kpi=use_kpi,
|
|
1360
1371
|
)
|
|
1361
1372
|
list_sorted_channels_cost = list(
|
|
1362
1373
|
data.sel(spend_multiplier=1)
|