![]() |
Generates media effects plots for the Meridian model.
meridian.analysis.visualizer.MediaEffects(
meridian: meridian.model.model.Meridian
,
by_reach: bool = True
)
Plots incremental outcome and effectiveness for all channels.
Methods
adstock_decay_dataframe
adstock_decay_dataframe(
confidence_level: float = c.DEFAULT_CONFIDENCE_LEVEL
) -> pd.DataFrame
A DataFrame holding the calculated Adstock decay metrics.
The DataFrame contains the following columns:
time_units
, channel
, distribution
, mean
, ci_lo
, ci_hi
.
Args:
confidence_level: Confidence level for modeled adstock decay credible
intervals, represented as a value between zero and one. Default is 0.9.
Returns | |
---|---|
A DataFrame displaying the adstock decay metrics. |
hill_curves_dataframe
hill_curves_dataframe(
confidence_level: float = c.DEFAULT_CONFIDENCE_LEVEL
) -> pd.DataFrame
A DataFrame holding the calculated Hill curve metrics.
The DataFrame contains the following columns:
channel
, media_units
, ci_hi
, ci_lo
, mean
, channel_type
,
scaled_count_histogram
, start_interval_histogram
,
end_interval_histogram
.
Args:
confidence_level: Confidence level for modeled hill curves credible
intervals, represented as a value between zero and one. Default is 0.9.
Returns | |
---|---|
Hill curves pd.DataFrame with columns:
|
plot_adstock_decay
plot_adstock_decay(
confidence_level: float = c.DEFAULT_CONFIDENCE_LEVEL,
include_ci: bool = True
)
Plots the Adstock decay for each channel.
Args | |
---|---|
confidence_level
|
Confidence level to update to for the adstock decay credible intervals, represented as a value between zero and one. |
include_ci
|
If True , plots the credible interval. Defaults to True .
|
Returns | |
---|---|
An Altair plot showing the Adstock decay prior and posterior per media. |
plot_hill_curves
plot_hill_curves(
confidence_level: float = c.DEFAULT_CONFIDENCE_LEVEL,
include_prior: bool = True,
include_ci: bool = True
) -> Mapping[str, alt.Chart]
Plots the Hill curves for each channel.
Args | |
---|---|
confidence_level
|
Confidence level to update to for the hill curves credible intervals, represented as a value between zero and one. |
include_prior
|
If True , plots contain both the prior and posterior.
Defaults to True .
|
include_ci
|
If True , plots the credible interval. Defaults to True .
|
Returns | |
---|---|
A dictionary mapping channel type constants (media , rf ,
organic_media , and organic_rf ) to their respective Altair chart
objects. Keys are only present if charts for that type were generated
(i.e., if the corresponding channels exist in the data). Returns an empty
dictionary if no relevant channels are found.
|
plot_response_curves
plot_response_curves(
confidence_level: float = c.DEFAULT_CONFIDENCE_LEVEL,
selected_times: (frozenset[str] | None) = None,
by_reach: bool = True,
plot_separately: bool = True,
include_ci: bool = True,
num_channels_displayed: (int | None) = None
) -> alt.Chart
Plots the response curves for each channel.
To avoid congestion when the channels are plotted in the same graph, we cap the number of channels that can be displayed visually on the graph to 7 channels maximum. If the num_channels_displayed is greater than the total number of channels in the dataset, the total number of channels in the dataset is displayed.
Args | |
---|---|
confidence_level
|
Confidence level to update to for the response curve credible intervals, represented as a value between zero and one. |
selected_times
|
Optional list containing a subset of time dimensions to
include. The x-axis corresponds to spend within these time periods. The
y-axis corresponds to the incremental outcome generated within these
time periods under the counterfactual where media units in each geo and
time period are multiplied by the corresponding multiplier (including
time periods prior to to selected_times ). By default, all time periods
are included.
|
by_reach
|
For the channel w/ reach and frequency, return the response curves by reach given fixed frequency if true; return the response curves by frequency given fixed reach if false. |
plot_separately
|
If True , the plots are faceted. If False , the plots
are layered to create one plot with all of the channels.
|
include_ci
|
If True , plots the credible interval. Defaults to True .
|
num_channels_displayed
|
Number of channels to show on the layered plot. If plotting a faceted chart, this value is ignored. |
Returns | |
---|---|
An Altair plot showing the response curves per channel. |
response_curves_data
response_curves_data(
confidence_level: float = c.DEFAULT_CONFIDENCE_LEVEL,
selected_times: (frozenset[str] | None) = None,
by_reach: bool = True
) -> xr.Dataset
Dataset holding the calculated response curves data.
The dataset contains the following:
- Coordinates:
media
,metric
(mean
,ci_hi
,ci_lo
),spend_multiplier
- Data variables:
spend
,incremental_outcome
,roi
Args | |
---|---|
confidence_level
|
Confidence level for modeled response credible intervals, represented as a value between zero and one. Default is 0.9. |
selected_times
|
Optional list containing a subset of time dimensions to
include. The x-axis corresponds to spend within these time periods. The
y-axis corresponds to the incremental outcome generated within these
time periods under the counterfactual where media units in each geo and
time period are scaled by the ratio of x-axis spend to historical spend.
(Media units for time periods prior to to selected_times are also
scaled by this ratio). By default, all times are included. Times should
match the time dimensions from meridian.InputData .
|
by_reach
|
For the channel w/ reach and frequency, return the response curves by reach given fixed frequency if true; return the response curves by frequency given fixed reach if false. |
Returns | |
---|---|
A Dataset displaying the response curves data. |