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.
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.
pd.DataFrame
with columns: -
channel
:media
orrf
channel name. -
media_units
: Media (formedia
channels) or average frequency (forrf
channels) units. -
distribution
: Indication ofposterior
orprior
draw. -
ci_hi
: Upper bound of the credible interval of the value of the Hill function. -
ci_lo
: Lower bound of the credible interval of the value of the Hill function. -
mean
: Point-wise mean of the value of the Hill function per draw. -
channel_type
: Indication of amedia
orrf
channel. -
scaled_count_histogram
: Scaled count of media units or average frequencies within the bin. -
count_histogram
: Count value of media units or average frequencies within the bin. -
start_interval_histogram
: Media unit or average frequency starting point for a histogram bin. -
end_interval_histogram
: Media unit or average frequency ending point for a histogram bin.
plot_adstock_decay
plot_adstock_decay
(
confidence_level
:
float
=
c
.
DEFAULT_CONFIDENCE_LEVEL
,
include_ci
:
bool
=
True
)
Plots the Adstock decay for each channel.
confidence_level
include_ci
True
, plots the credible interval. Defaults to True
.
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.
confidence_level
include_prior
True
, plots contain both the prior and posterior.
Defaults to True
.include_ci
True
, plots the credible interval. Defaults to True
.
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.
confidence_level
selected_times
selected_times
). By default, all time periods
are included.by_reach
plot_separately
True
, the plots are faceted. If False
, the plots
are layered to create one plot with all of the channels.include_ci
True
, plots the credible interval. Defaults to True
.num_channels_displayed
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
confidence_level
selected_times
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