meridian.analysis.visualizer.ModelDiagnostics

Generates model diagnostics plots from the Meridian model fitting.

Methods

plot_prior_and_posterior_distribution

View source

Plots prior and posterior distributions for a model parameter.

Args

parameter
Model parameter name to plot. By default, the ROI parameter is shown if a name is not specified.
num_geos
Number of largest geos by population to show in the plots for the geo-level parameters. By default, only the top three largest geos are shown.
selected_times
List of specific time periods to plot for time-level parameters. These times must match the time periods from the data. By default, the first three time periods are plotted.

Returns
An Altair plot showing the parameter distributions.

Raises

NotFittedModelError
The model hasn't been fitted.
ValueError
A parameter is not a Meridian model parameter.

plot_rhat_boxplot

View source

Plots the R-hat box plot.

Visual summary of the Gelman & Rubin (1992) potential scale reduction for chain convergence, commonly referred to as R-hat. It is a convergence diagnostic measure that measures the degree to which variance (of the means) between chains exceeds what you would expect if the chains were identically distributed. Values close to 1.0 indicate convergence. R-hat < 1.2 indicates approximate convergence and is a reasonable threshold for many problems (Brooks & Gelman, 1998).

There is a single R-hat value for each model parameter. The box plot summarizes the distribution of R-hat values across indices. For example, the box corresponding to beta_gm summarizes the distribution of R-hat values across both the geo index g and the channel index m .

The R-hat is not defined for any parameters that have deterministic priors, so these parameters are not shown on the boxplot.

References
Andrew Gelman and Donald B. Rubin. Inference from Iterative Simulation Using Multiple Sequences. Statistical Science, 7(4):457-472, 1992. Stephen P. Brooks and Andrew Gelman. General Methods for Monitoring Convergence of Iterative Simulatio

Returns
An Altair plot showing the R-hat boxplot per parameter.

Raises

NotFittedModelError
The model hasn't been fitted.
MCMCSamplingError
The MCMC sampling did not converge.

predictive_accuracy_table

View source

Displays the predictive accuracy of the DataFrame.

Args

selected_geos
Optional list of a subset of geo dimensions to include. By default, all geos are included. Geos should match the geo dimension names from meridian.InputData . Set either selected_geos or n_top_largest_geos , do not set both.
selected_times
Optional list of a subset of time dimensions to include. By default, all times are included. Times must match the time dimensions from meridian.InputData .
column_var
Optional string that indicates whether to pivot the table by metric , geo_granularity or evaluation_set . By default, column_var=None indicates that the metric , geo_granularity and value (along with evaluation_set when holdout_id isn't None ) columns are displayed in the returning unpivoted DataFrame.
batch_size
Integer representing the number of maximum draws per chain in each batch. The calculation is run in batches to avoid memory exhaustion. If a memory error occurs, try reducing batch_size . The calculation will generally be faster with larger batch_size values.

Returns
A DataFrame containing the computed R_Squared , MAPE and wMAPE values. If holdout_id exists, the data is split into Train , Test , and All Data subsections, and evaluation_set is included as a column in the transformation from Dataset to DataFrame.

Design a Mobile Site
View Site in Mobile | Classic
Share by: