Join the newly launched Discord
community for real-time discussions, peer support, and direct interaction with the Meridian team!
meridian.model.media.MediaTensors
Stay organized with collections
Save and categorize content based on your preferences.
Container for (paid) media tensors.
meridian
.
model
.
media
.
MediaTensors
(
media
:
(
meridian
.
backend
.
Tensor
|
None
)
=
None
,
media_spend
:
(
meridian
.
backend
.
Tensor
|
None
)
=
None
,
media_transformer
:
(
meridian
.
model
.
transformers
.
MediaTransformer
|
None
)
=
None
,
media_scaled
:
(
meridian
.
backend
.
Tensor
|
None
)
=
None
,
prior_media_scaled_counterfactual
:
(
meridian
.
backend
.
Tensor
|
None
)
=
None
,
prior_denominator
:
(
meridian
.
backend
.
Tensor
|
None
)
=
None
)
A MediaTransformer
to scale media tensors using the
model's media data.
The media tensor normalized by population and by the median
value.
prior_media_scaled_counterfactual
A tensor containing media_scaled
values
corresponding to the counterfactual scenario required for the prior
calculation. For ROI priors, the counterfactual scenario is where media is
set to zero during the calibration period. For mROI priors, the
counterfactual scenario is where media is increased by a small factor for
all n_media_times
. For contribution priors, the counterfactual scenario
is where media is set to zero for all n_media_times
. This attribute is
set to None
when it would otherwise be a tensor of zeros, i.e., when
contribution contribution priors are used, or when ROI priors are used and roi_calibration_period
is None
.
If ROI, mROI, or contribution priors are used, this
represents the denominator. It is a tensor with dimension equal to n_media_channels
. For ROI priors, it is the spend during the overlapping
time periods between the calibration period and the modeling time window.
For mROI priors, it is the ROI prior denominator multiplied by a small
factor. For contribution priors, it is the total observed outcome
(repeated for each channel.)
Methods
__eq__
__eq__
(
other
)
Return self==value.
prior_media_scaled_counterfactual
None
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
, and code samples are licensed under the Apache 2.0 License
. For details, see the Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-09-05 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-05 UTC."],[[["\u003cp\u003e\u003ccode\u003eMediaTensors\u003c/code\u003e is a container for various media-related tensors used in a model, including media, media spend, and their counterfactual versions.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003emedia_transformer\u003c/code\u003e attribute within \u003ccode\u003eMediaTensors\u003c/code\u003e is utilized to scale media tensors based on the model's media data.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eMediaTensors\u003c/code\u003e includes both scaled and unscaled versions of the media tensors, namely \u003ccode\u003emedia_scaled\u003c/code\u003e and \u003ccode\u003emedia\u003c/code\u003e, which helps to provide a normalized view of the media data.\u003c/p\u003e\n"],["\u003cp\u003eCounterfactual tensors like \u003ccode\u003emedia_counterfactual\u003c/code\u003e and \u003ccode\u003emedia_spend_counterfactual\u003c/code\u003e are used to calculate ROI by comparing expected sales or spend differences with their base counterparts, \u003ccode\u003emedia\u003c/code\u003e and \u003ccode\u003emedia_spend\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003e__eq__\u003c/code\u003e method is defined for \u003ccode\u003eMediaTensors\u003c/code\u003e, allowing for comparison of \u003ccode\u003eMediaTensor\u003c/code\u003e objects.\u003c/p\u003e\n"]]],["`MediaTensors` is a container for media-related tensors, including `media`, `media_spend`, `media_scaled`, and counterfactual versions. `media` and `media_spend` are derived from input data. `media_scaled` is normalized media data. Counterfactual tensors (`media_counterfactual`, `media_spend_counterfactual`, `media_counterfactual_scaled`) are used to calculate ROI based on differences in sales or spend. The `MediaTransformer` scales media tensors. The class also defines an `__eq__` method and various class variables, to define the tensor data stored.\n"],null,["\u003cbr /\u003e\n\n|---------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/google/meridian/blob/v1.2.0/meridian/model/media.py#L57-L92) |\n\nContainer for (paid) media tensors. \n\n meridian.model.media.MediaTensors(\n media: (../../../meridian/backend/Tensor.md | None) = None,\n media_spend: (../../../meridian/backend/Tensor.md | None) = None,\n media_transformer: (../../../meridian/model/transformers/MediaTransformer.md | None) = None,\n media_scaled: (../../../meridian/backend/Tensor.md | None) = None,\n prior_media_scaled_counterfactual: (../../../meridian/backend/Tensor.md | None) = None,\n prior_denominator: (../../../meridian/backend/Tensor.md | None) = None\n )\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ||\n|-------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `media` | A tensor constructed from [`InputData.media`](../../../meridian/data/input_data/InputData.md#media). |\n| `media_spend` | A tensor constructed from [`InputData.media_spend`](../../../meridian/data/input_data/InputData.md#media_spend). |\n| `media_transformer` | A `MediaTransformer` to scale media tensors using the model's media data. |\n| `media_scaled` | The media tensor normalized by population and by the median value. |\n| `prior_media_scaled_counterfactual` | A tensor containing `media_scaled` values corresponding to the counterfactual scenario required for the prior calculation. For ROI priors, the counterfactual scenario is where media is set to zero during the calibration period. For mROI priors, the counterfactual scenario is where media is increased by a small factor for all `n_media_times`. For contribution priors, the counterfactual scenario is where media is set to zero for all `n_media_times`. This attribute is set to `None` when it would otherwise be a tensor of zeros, i.e., when contribution contribution priors are used, or when ROI priors are used and `roi_calibration_period` is `None`. |\n| `prior_denominator` | If ROI, mROI, or contribution priors are used, this represents the denominator. It is a tensor with dimension equal to `n_media_channels`. For ROI priors, it is the spend during the overlapping time periods between the calibration period and the modeling time window. For mROI priors, it is the ROI prior denominator multiplied by a small factor. For contribution priors, it is the total observed outcome (repeated for each channel.) |\n\n\u003cbr /\u003e\n\nMethods\n\n`__eq__` \n\n __eq__(\n other\n )\n\nReturn self==value.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Class Variables ||\n|-----------------------------------|--------|\n| media | `None` |\n| media_scaled | `None` |\n| media_spend | `None` |\n| media_transformer | `None` |\n| prior_denominator | `None` |\n| prior_media_scaled_counterfactual | `None` |\n\n\u003cbr /\u003e"]]