Handles EDA report generation and visualization for a Meridian model.
meridian.model.eda.meridian_eda.MeridianEDA(
meridian: model.Meridian,
*,
n_draws_prior: int = eda_constants.DEFAULT_PRIOR_N_DRAW,
seed: int = eda_constants.DEFAULT_PRIOR_SEED
)
Args |
meridian
|
Meridian object.
|
n_draws_prior
|
Number of draws for prior distribution check. Only used if
no prior samples exist in meridian.inference_data.
|
seed
|
Seed for prior distribution check. Only used if no prior samples
exist in meridian.inference_data.
|
Attributes |
critical_outcomes
|
|
eda_engine
|
|
geo_cost_per_media_unit_check_outcome
|
|
geo_pairwise_correlation_check_outcome
|
|
geo_stdev_check_outcome
|
|
national_cost_per_media_unit_check_outcome
|
|
national_pairwise_correlation_check_outcome
|
|
national_stdev_check_outcome
|
|
Methods
generate_and_save_report
View source
generate_and_save_report(
filename: str, filepath: str
) -> None
Generates and saves a HTML report containing EDA findings.
| Args |
filename
|
The filename for the generated HTML output.
|
filepath
|
The path to the directory where the file will be saved.
|
View source
plot_controls_and_non_media_boxplot(
geos: Geos = 1, max_vars: (int | None) = None
) -> alt.Chart
Plots the boxplots for controls and non-media treatments variation.
View source
plot_cost_per_media_unit_time_series(
geos: Geos = 1, channels: (Sequence[str] | None) = None
) -> alt.Chart
Plots cost per media unit time series for paid media channels.
| Args |
geos
|
The geos to plot.
|
channels
|
The channels to plot. If None, plots all channels.
|
| Returns |
|
The cost per media unit time series plot and the superimposed cost with
media unit time series plot for each paid media channel.
|
plot_kpi_boxplot
View source
plot_kpi_boxplot(
geos: Geos = 1
) -> alt.Chart
Plots the boxplot for KPI variation.
plot_national_kpi_with_knots_time_series
View source
plot_national_kpi_with_knots_time_series() -> alt.Chart
Plots the national scaled KPI with knots time series plot.
plot_pairwise_correlation
View source
plot_pairwise_correlation(
geos: Geos = 1, max_vars: (int | None) = None
) -> alt.Chart
Plots the Pairwise Correlation data.
| Args |
geos
|
Defines which geos to plot. - int: The number of top geos to plot,
ranked by population. - Sequence[str]: A specific sequence of geo names
to plot. - 'nationalize': Aggregates all geos into a single national
view. Defaults to 1 (plotting the top geo). If the data is already at a
national level, this parameter is ignored and a national plot is
generated.
|
max_vars
|
The maximum number of variables to include in the correlation
heatmap. Variables are selected based on their absolute correlation
values. If None, all variables are included.
|
| Returns |
|
Altair chart(s) of the Pairwise Correlation data.
|
| Raises |
ValueError
|
If max_vars is less than or equal to 1.
|
View source
plot_population_raw_media_correlation() -> alt.Chart
Plots Spearman correlation between population and raw media units.
| Returns |
|
A bar chart showing the correlation.
|
| Raises |
eda_engine_module.GeoLevelCheckOnNationalModelError
|
If the Meridian model
is national.
|
plot_population_treatment_correlation
View source
plot_population_treatment_correlation() -> alt.Chart
Plots the Spearman correlation of population vs treatments or controls.
| Returns |
|
An Altair chart showing the correlation.
|
| Raises |
eda_engine_module.GeoLevelCheckOnNationalModelError
|
If the Meridian model
is national.
|
plot_prior_mean
View source
plot_prior_mean() -> alt.Chart
Plots the prior mean of contribution by channel.
| Returns |
|
A bar chart showing the prior mean of contribution by channel.
|
| Raises |
eda_engine_module.GeoLevelCheckOnNationalModelError
|
If the Meridian model
is national.
|
plot_relative_impression_share_barchart
View source
plot_relative_impression_share_barchart(
geos: Geos = 1, n_channels: (int | None) = None, ascending: bool = True
) -> alt.Chart
Plots a bar chart of the relative impression share per media channel.
| Args |
geos
|
The geos to plot.
|
n_channels
|
The number of channels to display by impression share. If
None, displays all channels.
|
ascending
|
Whether to sort the channels in ascending order by impression
share.
|
| Returns |
|
The bar chart of the relative impression share of each media channel.
|
plot_relative_spend_share_barchart
View source
plot_relative_spend_share_barchart(
geos: Geos = 1, n_channels: (int | None) = None, ascending: bool = True
) -> alt.Chart
Plots a bar chart of the relative spend share per paid media channel.
| Args |
geos
|
The geos to plot.
|
n_channels
|
The number of channels to display by spend share. If None,
displays all channels.
|
ascending
|
Whether to sort the channels in ascending order by spend share.
|
| Returns |
|
The bar chart of the relative spend share of each paid media channel.
|
View source
plot_treatments_without_non_media_boxplot(
geos: Geos = 1, max_vars: (int | None) = None
) -> alt.Chart
Plots the boxplot for treatments variation, excluding non-media.