meridian.analysis.visualizer.MediaSummary

Generates media summary metrics plots for the Meridian model.

Calculates the mean and credible intervals (CI) for each channel's outcome metrics (incremental outcome, contribution, ROI, mROI, effectiveness) and media summary metrics (impressions, spend). Metrics are calculated at the national-level. These are used for various plots displaying these metrics.

meridian
Media mix model with the raw data from the model fitting.
confidence_level
Confidence level for media summary metrics credible intervals, represented as a value between zero and one.
selected_times
Optional list containing a subset of times to include. By default, all time periods are included.
marginal_roi_by_reach
Boolean. Marginal ROI is defined as the return on the next dollar spent. If this argument is True, then we assume the next dollar spent only impacts reach, holding frequency constant. If this argument is False, we assume the next dollar spent only impacts frequency, holding reach constant.
non_media_baseline_values
Optional list of shape (n_non_media_channels,) . Each element is a float denoting the fixed value which will be used as baseline for the given channel. If None , the values defined with ModelSpec.non_media_baseline_values will be used.

all_summary_metrics

paid_summary_metrics

Methods

contribution_metrics

View source

Transforms the media metrics for the contribution plot.

This adds the calculations for incremental outcome and percentages of the expected outcome for the baseline, where there is no media effects. It also transforms the percentages to values between 0 and 1 for Altair to format when plotting.

Args

selected_channels
Optional list of a subset of channels to filter by.
include_non_paid
If True , includes the organic media, organic RF and non-media channels in the contribution plot. Defaults to False .
aggregate_times
If True , aggregates the metrics across all time periods. If False , returns time-varying metrics.

Returns
A dataframe with contributions per channel.

get_all_summary_metrics

View source

Dataset holding the calculated summary metrics for all channels.

Args

aggregate_times
If True , aggregates the metrics across all time periods. If False , returns time-varying metrics.

Returns
An xarray.Dataset containing the following: - Coordinates: channel , metric ( mean , median , ci_lo , ci_hi ), distribution ( prior , posterior ) - Data variables: incremental_outcome , pct_of_contribution , effectiveness .

get_paid_summary_metrics

View source

Dataset holding the calculated summary metrics for the paid channels.

Args

aggregate_times
If True , aggregates the metrics across all time periods. If False , returns time-varying metrics.

Returns
An xarray.Dataset containing the following: - Coordinates: channel , metric ( mean , median , ci_lo , ci_hi ), distribution ( prior , posterior ) - Data variables: impressions , pct_of_impressions , spend , pct_of_spend , CPM , incremental_outcome , pct_of_contribution , roi , effectiveness , mroi .

plot_channel_contribution_area_chart

View source

Plots a stacked area chart of the contribution share per channel by time.

Args

time_granularity
The granularity for the time axis. Options are weekly or quarterly . Defaults to quarterly .

Returns
An Altair plot showing the contribution share per channel by time.

Raises

ValueError
If time_granularity is not one of the allowed constants.

plot_channel_contribution_bump_chart

View source

Plots a bump chart of channel contribution rank over time.

This chart shows the relative rank of each channel's contribution, including the baseline, based on incremental outcome. Depending on the time_granularity, ranks are shown either weekly or at the end of each quarter. Rank 1 represents the highest contribution.

Args

time_granularity
The granularity for the time axis. Options are weekly or quarterly . Defaults to quarterly .

Returns
An Altair plot showing the contribution rank per channel by time.

Raises

ValueError
If time_granularity is not one of the allowed constants.

plot_contribution_pie_chart

View source

Plots a pie chart of the total contributions from channels.

Returns
An Altair plot showing the contributions for all channels.

plot_contribution_waterfall_chart

View source

Plots a waterfall chart of the contribution share per channel.

Returns
An Altair plot showing the contributions per channel.

plot_cpik

View source

Plots the CPIK bar chart for each channel.

Args

include_ci
If True , plots the credible interval. Defaults to True .

Returns
An Altair plot showing the CPIK per channel.

plot_roi_bar_chart

View source

Plots the ROI bar chart for each channel.

Args

include_ci
If True , plots the credible interval. Defaults to True .

Returns
An Altair plot showing the ROI per channel.

plot_roi_vs_effectiveness

View source

Plots the ROI versus effectiveness bubble chart.

This chart compares the ROI, effectiveness, and spend for each media channel. Spend is depicted by the pixel area of the bubble.

Args

selected_channels
List of channels to include. If None , all of the media channels are shown in the plot.
disable_size
If True , disables the different sizing of the bubbles and plots each channel uniformly. Defaults to False .

Returns
An Altair plot showing the ROI and effectiveness per channel.

plot_roi_vs_mroi

View source

Plots the ROI versus mROI bubble chart.

This chart compares the ROI, mROI, and spend for each channel. Spend is depicted by the pixel area of the bubble.

Args

selected_channels
List of channels to include. If None , all of the media channels are shown in the plot.
disable_size
If True , disables the different sizing of the bubbles and plots each channel uniformly. Defaults to False .
equal_axes
If True , plots the X and Y axes with equal scale. Defaults to False .

Returns
An Altair plot showing the ROI and mROI per channel.

plot_spend_vs_contribution

View source

Plots a bar chart comparing spend versus contribution shares per channel.

This compares the spend and contribution percentages for each channel, and the ROI per channel. The contribution percentages are out of the total media-driven outcome amount.

Returns
An Altair plot showing the spend versus outcome percentages per channel.

summary_table

View source

Returns a formatted dataframe table of the summary metrics.

Mean and credible interval summary metrics are formatted as text.

Args

include_prior
If True, prior distribution summary metrics are included. One of include_prior and include_posterior must be True.
include_posterior
If True, posterior distribution summary metrics are included. One of include_prior and include_posterior must be True.
include_non_paid_channels
Boolean. If True , non-paid channels (organic media, organic reach and frequency, and non-media treatments) are included in the summary but only the metrics independent of spend are reported. If False , only the paid channels (media, reach and frequency) are included but the summary contains also the metrics dependent on spend. Default: False .

Returns
pandas.DataFrame of formatted summary metrics.

update_summary_metrics

View source

Runs the computation for the media summary metrics with new parameters.

Args

confidence_level
Confidence level to update to for the media summary metrics credible intervals, represented as a value between zero and one. If None , the current confidence level is used.
selected_times
Optional list containing a subset of times to include. If None , all time periods are included.
marginal_roi_by_reach
Boolean. Marginal ROI is defined as the return on the next dollar spent. If True , then the assumptions is the next dollar spent only impacts reach, holding frequency constant. If False , the assumption is the next dollar spent only impacts frequency, holding reach constant.
non_media_baseline_values
Optional list of shape (n_non_media_channels,) . Each element is a float denoting the fixed value which will be used as baseline for the given channel. If None , the values defined with ModelSpec.non_media_baseline_values will be used.

Create a Mobile Website
View Site in Mobile | Classic
Share by: