google-meridian 1.0.1__py3-none-any.whl → 1.0.3__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.0.1.dist-info → google_meridian-1.0.3.dist-info}/METADATA +25 -5
- {google_meridian-1.0.1.dist-info → google_meridian-1.0.3.dist-info}/RECORD +7 -7
- meridian/__init__.py +1 -1
- meridian/analysis/analyzer.py +59 -23
- {google_meridian-1.0.1.dist-info → google_meridian-1.0.3.dist-info}/LICENSE +0 -0
- {google_meridian-1.0.1.dist-info → google_meridian-1.0.3.dist-info}/WHEEL +0 -0
- {google_meridian-1.0.1.dist-info → google_meridian-1.0.3.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: google-meridian
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.3
|
|
4
4
|
Summary: Google's open source mixed marketing model library, helps you understand your return on investment and direct your ad spend with confidence.
|
|
5
5
|
Author-email: The Meridian Authors <no-reply@google.com>
|
|
6
6
|
License:
|
|
@@ -236,6 +236,8 @@ Requires-Dist: pylint>=2.6.0; extra == "dev"
|
|
|
236
236
|
Requires-Dist: pyink; extra == "dev"
|
|
237
237
|
Provides-Extra: colab
|
|
238
238
|
Requires-Dist: psutil; extra == "colab"
|
|
239
|
+
Provides-Extra: and-cuda
|
|
240
|
+
Requires-Dist: tensorflow[and-cuda]<2.17,>=2.16; extra == "and-cuda"
|
|
239
241
|
|
|
240
242
|
# About Meridian
|
|
241
243
|
|
|
@@ -271,11 +273,19 @@ you understand the differences between these MMM projects.
|
|
|
271
273
|
Python 3.11 or 3.12 is required to use Meridian. We also recommend using a
|
|
272
274
|
minimum of 1 GPU.
|
|
273
275
|
|
|
274
|
-
Note: This project has been tested on
|
|
276
|
+
Note: This project has been tested on T4 GPU using 16 GB of RAM.
|
|
275
277
|
|
|
276
278
|
To install Meridian, run the following command to automatically install the
|
|
277
279
|
latest release from PyPI.
|
|
278
280
|
|
|
281
|
+
For GPU users (requires CUDA toolchain to already be installed in the system):
|
|
282
|
+
|
|
283
|
+
```sh
|
|
284
|
+
$ pip install --upgrade google-meridian[and-cuda]
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
For CPU users:
|
|
288
|
+
|
|
279
289
|
```sh
|
|
280
290
|
$ pip install --upgrade google-meridian
|
|
281
291
|
```
|
|
@@ -283,13 +293,22 @@ $ pip install --upgrade google-meridian
|
|
|
283
293
|
Alternatively, run the following command to install the most recent, unreleased
|
|
284
294
|
version from GitHub.
|
|
285
295
|
|
|
296
|
+
For GPU users (requires CUDA toolchain to already be installed in the system):
|
|
297
|
+
|
|
298
|
+
```sh
|
|
299
|
+
$ pip install --upgrade "google-meridian[and-cuda] @ git+https://github.com/google/meridian.git"
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
For CPU users:
|
|
303
|
+
|
|
286
304
|
```sh
|
|
287
305
|
$ pip install --upgrade git+https://github.com/google/meridian.git
|
|
288
306
|
```
|
|
289
307
|
|
|
290
308
|
We recommend to install Meridian in a fresh
|
|
291
309
|
[virtual environment](https://virtualenv.pypa.io/en/latest/user_guide.html#quick-start)
|
|
292
|
-
to make sure that correct versions of all the dependencies are installed, as
|
|
310
|
+
to make sure that correct versions of all the dependencies are installed, as
|
|
311
|
+
defined in [pyproject.toml](https://github.com/google/meridian/blob/main/pyproject.toml).
|
|
293
312
|
|
|
294
313
|
## How to use the Meridian library
|
|
295
314
|
|
|
@@ -362,12 +381,13 @@ this.
|
|
|
362
381
|
|
|
363
382
|
To cite this repository:
|
|
364
383
|
|
|
365
|
-
|
|
384
|
+
<!-- mdlint off(SNIPPET_INVALID_LANGUAGE) -->
|
|
385
|
+
```BibTeX
|
|
366
386
|
@software{meridian_github,
|
|
367
387
|
author = {Google Meridian Marketing Mix Modeling Team},
|
|
368
388
|
title = {Meridian: Marketing Mix Modeling},
|
|
369
389
|
url = {https://github.com/google/meridian},
|
|
370
|
-
version = {1.0.
|
|
390
|
+
version = {1.0.3},
|
|
371
391
|
year = {2025},
|
|
372
392
|
}
|
|
373
393
|
```
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
meridian/__init__.py,sha256=
|
|
1
|
+
meridian/__init__.py,sha256=s6xSABYTSpITfC_qBN0xZkps655MgpI3P_3mzo8HchA,714
|
|
2
2
|
meridian/constants.py,sha256=PhQX3S0b-Odv_bjl1YaO6vnLT4rBomiAcec0789VZNE,14599
|
|
3
3
|
meridian/analysis/__init__.py,sha256=-FooDZ5OzePpyTVkvRoWQx_xBaRR_hjVLny9H8-kkyQ,836
|
|
4
|
-
meridian/analysis/analyzer.py,sha256=
|
|
4
|
+
meridian/analysis/analyzer.py,sha256=I08vm0wkpvwGYb_MpJFb3nh6uIVqGGkIjtOmvTYWml0,204803
|
|
5
5
|
meridian/analysis/formatter.py,sha256=WpV9O_SznsSfJmx36V8nycXOA1g2nhZ9J5sm7kZ_QIQ,6821
|
|
6
6
|
meridian/analysis/optimizer.py,sha256=4e-SN6WMqBzaEgWDB0sok91N_v5gCdhXfFVyH5f4OWI,72365
|
|
7
7
|
meridian/analysis/summarizer.py,sha256=jzkmUNUy3lztPFcSj6XzGsmx39FqdmmsDzZ_G-g9Idk,17480
|
|
@@ -30,8 +30,8 @@ meridian/model/model.py,sha256=y7KxKADR0i9JiTLOAeTRXF8mg2DBDb615B4oG-wEpK4,79228
|
|
|
30
30
|
meridian/model/prior_distribution.py,sha256=6fqx_XIM0DSQICd65XaSRhelsjvZ4ariBfeyOeoKld8,39075
|
|
31
31
|
meridian/model/spec.py,sha256=xaHxfCLWLnWMAkMy2ouDoqGBHI_4tzzX8AaJOsKdu7Q,8878
|
|
32
32
|
meridian/model/transformers.py,sha256=te3OJixprWLtv7O00a9GZWE4waTS94NNLVo3tWIl1-k,7420
|
|
33
|
-
google_meridian-1.0.
|
|
34
|
-
google_meridian-1.0.
|
|
35
|
-
google_meridian-1.0.
|
|
36
|
-
google_meridian-1.0.
|
|
37
|
-
google_meridian-1.0.
|
|
33
|
+
google_meridian-1.0.3.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
|
34
|
+
google_meridian-1.0.3.dist-info/METADATA,sha256=SzPsRTObvuc5zbyrPnvGJ_5_YMD6A_UidLA5gWDSwQs,21916
|
|
35
|
+
google_meridian-1.0.3.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
36
|
+
google_meridian-1.0.3.dist-info/top_level.txt,sha256=nwaCebZvvU34EopTKZsjK0OMTFjVnkf4FfnBN_TAc0g,9
|
|
37
|
+
google_meridian-1.0.3.dist-info/RECORD,,
|
meridian/__init__.py
CHANGED
meridian/analysis/analyzer.py
CHANGED
|
@@ -2568,6 +2568,7 @@ class Analyzer:
|
|
|
2568
2568
|
aggregate_geos: bool = False,
|
|
2569
2569
|
aggregate_times: bool = False,
|
|
2570
2570
|
split_by_holdout_id: bool = False,
|
|
2571
|
+
non_media_baseline_values: Sequence[str | float] | None = None,
|
|
2571
2572
|
confidence_level: float = constants.DEFAULT_CONFIDENCE_LEVEL,
|
|
2572
2573
|
) -> xr.Dataset:
|
|
2573
2574
|
"""Calculates the data for the expected versus actual outcome over time.
|
|
@@ -2579,6 +2580,13 @@ class Analyzer:
|
|
|
2579
2580
|
are summed over all of the time periods.
|
|
2580
2581
|
split_by_holdout_id: Boolean. If `True` and `holdout_id` exists, the data
|
|
2581
2582
|
is split into `'Train'`, `'Test'`, and `'All Data'` subsections.
|
|
2583
|
+
non_media_baseline_values: Optional list of shape (n_non_media_channels,).
|
|
2584
|
+
Each element is either a float (which means that the fixed value will be
|
|
2585
|
+
used as baseline for the given channel) or one of the strings "min" or
|
|
2586
|
+
"max" (which mean that the global minimum or maximum value will be used
|
|
2587
|
+
as baseline for the values of the given non_media treatment channel). If
|
|
2588
|
+
None, the minimum value is used as baseline for each non_media treatment
|
|
2589
|
+
channel.
|
|
2582
2590
|
confidence_level: Confidence level for expected outcome credible
|
|
2583
2591
|
intervals, represented as a value between zero and one. Default: `0.9`.
|
|
2584
2592
|
|
|
@@ -2604,6 +2612,7 @@ class Analyzer:
|
|
|
2604
2612
|
aggregate_geos=False,
|
|
2605
2613
|
aggregate_times=False,
|
|
2606
2614
|
use_kpi=use_kpi,
|
|
2615
|
+
non_media_baseline_values=non_media_baseline_values,
|
|
2607
2616
|
)
|
|
2608
2617
|
baseline = self._mean_and_ci_by_eval_set(
|
|
2609
2618
|
baseline_expected_outcome,
|
|
@@ -2747,32 +2756,35 @@ class Analyzer:
|
|
|
2747
2756
|
"""Aggregates the incremental outcome of the media channels.
|
|
2748
2757
|
|
|
2749
2758
|
Args:
|
|
2750
|
-
use_posterior: Boolean. If `True
|
|
2751
|
-
calculated. Otherwise, the prior distribution is
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
`
|
|
2755
|
-
`revenue_per_kpi`. If
|
|
2756
|
-
the
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2759
|
+
use_posterior: Boolean. If `True`, then the incremental outcome posterior
|
|
2760
|
+
distribution is calculated. Otherwise, the prior distribution is
|
|
2761
|
+
calculated.
|
|
2762
|
+
new_data: Optional `DataTensors` container with optional tensors: `media`,
|
|
2763
|
+
`reach`, `frequency`, `organic_media`, `organic_reach`,
|
|
2764
|
+
`organic_frequency`, `non_media_treatments` and `revenue_per_kpi`. If
|
|
2765
|
+
`None`, the incremental outcome is calculated using the `InputData`
|
|
2766
|
+
provided to the Meridian object. If `new_data` is provided, the
|
|
2767
|
+
incremental outcome is calculated using the new tensors in `new_data`
|
|
2768
|
+
and the original values of the remaining tensors. For example,
|
|
2769
|
+
`compute_incremental_outcome_aggregate(new_data=DataTensors(media=new_media))`
|
|
2770
|
+
computes the incremental outcome using `new_media` and the original
|
|
2771
|
+
values of `reach`, `frequency`, `organic_media`, `organic_reach`,
|
|
2772
|
+
`organic_frequency`, `non_media_treatments` and `revenue_per_kpi`. If
|
|
2773
|
+
any of the tensors in `new_data` is provided with a different number of
|
|
2774
|
+
time periods than in `InputData`, then all tensors must be provided with
|
|
2775
|
+
the same number of time periods.
|
|
2761
2776
|
use_kpi: Boolean. If `True`, the summary metrics are calculated using KPI.
|
|
2762
2777
|
If `False`, the metrics are calculated using revenue.
|
|
2763
|
-
include_non_paid_channels: Boolean. If `True`, non-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
reported. If `False`, only the paid channels (media, reach and
|
|
2767
|
-
frequency) are included but the summary contains also the metrics
|
|
2768
|
-
dependent on spend. Default: `True`.
|
|
2778
|
+
include_non_paid_channels: Boolean. If `True`, then non-media treatments
|
|
2779
|
+
and organic effects are included in the calculation. If `False`, then
|
|
2780
|
+
only the paid media and RF effects are included.
|
|
2769
2781
|
non_media_baseline_values: Optional list of shape (n_non_media_channels,).
|
|
2770
2782
|
Each element is either a float (which means that the fixed value will be
|
|
2771
2783
|
used as baseline for the given channel) or one of the strings "min" or
|
|
2772
2784
|
"max" (which mean that the global minimum or maximum value will be used
|
|
2773
|
-
as baseline for the values of the given non_media
|
|
2774
|
-
|
|
2775
|
-
channel.
|
|
2785
|
+
as baseline for the scaled values of the given non_media treatments
|
|
2786
|
+
channel). If not provided, the minimum value is used as the baseline for
|
|
2787
|
+
each non_media treatments channel.
|
|
2776
2788
|
**kwargs: kwargs to pass to `incremental_outcome`, which could contain
|
|
2777
2789
|
selected_geos, selected_times, aggregate_geos, aggregate_times,
|
|
2778
2790
|
batch_size.
|
|
@@ -2814,6 +2826,7 @@ class Analyzer:
|
|
|
2814
2826
|
confidence_level: float = constants.DEFAULT_CONFIDENCE_LEVEL,
|
|
2815
2827
|
batch_size: int = constants.DEFAULT_BATCH_SIZE,
|
|
2816
2828
|
include_non_paid_channels: bool = False,
|
|
2829
|
+
non_media_baseline_values: Sequence[str | float] | None = None,
|
|
2817
2830
|
) -> xr.Dataset:
|
|
2818
2831
|
"""Returns summary metrics.
|
|
2819
2832
|
|
|
@@ -2880,6 +2893,13 @@ class Analyzer:
|
|
|
2880
2893
|
reported. If `False`, only the paid channels (media, reach and
|
|
2881
2894
|
frequency) are included but the summary contains also the metrics
|
|
2882
2895
|
dependent on spend. Default: `False`.
|
|
2896
|
+
non_media_baseline_values: Optional list of shape (n_non_media_channels,).
|
|
2897
|
+
Each element is either a float (which means that the fixed value will be
|
|
2898
|
+
used as baseline for the given channel) or one of the strings "min" or
|
|
2899
|
+
"max" (which mean that the global minimum or maximum value will be used
|
|
2900
|
+
as baseline for the values of the given non_media treatment channel). If
|
|
2901
|
+
None, the minimum value is used as baseline for each non_media treatment
|
|
2902
|
+
channel.
|
|
2883
2903
|
|
|
2884
2904
|
Returns:
|
|
2885
2905
|
An `xr.Dataset` with coordinates: `channel`, `metric` (`mean`, `median`,
|
|
@@ -2924,6 +2944,7 @@ class Analyzer:
|
|
|
2924
2944
|
new_data=new_data,
|
|
2925
2945
|
use_kpi=use_kpi,
|
|
2926
2946
|
include_non_paid_channels=include_non_paid_channels,
|
|
2947
|
+
non_media_baseline_values=non_media_baseline_values,
|
|
2927
2948
|
**dim_kwargs,
|
|
2928
2949
|
**batched_kwargs,
|
|
2929
2950
|
)
|
|
@@ -2932,6 +2953,7 @@ class Analyzer:
|
|
|
2932
2953
|
new_data=new_data,
|
|
2933
2954
|
use_kpi=use_kpi,
|
|
2934
2955
|
include_non_paid_channels=include_non_paid_channels,
|
|
2956
|
+
non_media_baseline_values=non_media_baseline_values,
|
|
2935
2957
|
**dim_kwargs,
|
|
2936
2958
|
**batched_kwargs,
|
|
2937
2959
|
)
|
|
@@ -3115,7 +3137,7 @@ class Analyzer:
|
|
|
3115
3137
|
**batched_kwargs,
|
|
3116
3138
|
# Drop mROI metric values in the Dataset's data_vars for the
|
|
3117
3139
|
# aggregated "All Paid Channels" channel dimension value.
|
|
3118
|
-
# "Marginal ROI"calculation must arbitrarily assume how the
|
|
3140
|
+
# "Marginal ROI" calculation must arbitrarily assume how the
|
|
3119
3141
|
# "next dollar" of spend is allocated across "All Paid Channels" in
|
|
3120
3142
|
# this case, which may cause confusion in Meridian model and does not
|
|
3121
3143
|
# have much practical usefulness, anyway.
|
|
@@ -3256,6 +3278,7 @@ class Analyzer:
|
|
|
3256
3278
|
selected_times: Sequence[str] | None = None,
|
|
3257
3279
|
aggregate_geos: bool = True,
|
|
3258
3280
|
aggregate_times: bool = True,
|
|
3281
|
+
non_media_baseline_values: Sequence[float | str] | None = None,
|
|
3259
3282
|
confidence_level: float = constants.DEFAULT_CONFIDENCE_LEVEL,
|
|
3260
3283
|
batch_size: int = constants.DEFAULT_BATCH_SIZE,
|
|
3261
3284
|
) -> xr.Dataset:
|
|
@@ -3270,6 +3293,13 @@ class Analyzer:
|
|
|
3270
3293
|
all of the regions.
|
|
3271
3294
|
aggregate_times: Boolean. If `True`, the expected outcome is summed over
|
|
3272
3295
|
all of the time periods.
|
|
3296
|
+
non_media_baseline_values: Optional list of shape (n_non_media_channels,).
|
|
3297
|
+
Each element is either a float (which means that the fixed value will be
|
|
3298
|
+
used as baseline for the given channel) or one of the strings "min" or
|
|
3299
|
+
"max" (which mean that the global minimum or maximum value will be used
|
|
3300
|
+
as baseline for the values of the given non_media treatment channel). If
|
|
3301
|
+
None, the minimum value is used as baseline for each non_media treatment
|
|
3302
|
+
channel.
|
|
3273
3303
|
confidence_level: Confidence level for media summary metrics credible
|
|
3274
3304
|
intervals, represented as a value between zero and one.
|
|
3275
3305
|
batch_size: Integer representing the maximum draws per chain in each
|
|
@@ -3345,13 +3375,19 @@ class Analyzer:
|
|
|
3345
3375
|
|
|
3346
3376
|
baseline_expected_outcome_prior = tf.expand_dims(
|
|
3347
3377
|
self._calculate_baseline_expected_outcome(
|
|
3348
|
-
use_posterior=False,
|
|
3378
|
+
use_posterior=False,
|
|
3379
|
+
use_kpi=use_kpi,
|
|
3380
|
+
non_media_baseline_values=non_media_baseline_values,
|
|
3381
|
+
**outcome_kwargs,
|
|
3349
3382
|
),
|
|
3350
3383
|
axis=-1,
|
|
3351
3384
|
)
|
|
3352
3385
|
baseline_expected_outcome_posterior = tf.expand_dims(
|
|
3353
3386
|
self._calculate_baseline_expected_outcome(
|
|
3354
|
-
use_posterior=True,
|
|
3387
|
+
use_posterior=True,
|
|
3388
|
+
use_kpi=use_kpi,
|
|
3389
|
+
non_media_baseline_values=non_media_baseline_values,
|
|
3390
|
+
**outcome_kwargs,
|
|
3355
3391
|
),
|
|
3356
3392
|
axis=-1,
|
|
3357
3393
|
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|