MMMPlotSuite.waterfall_components_decomposition#
- MMMPlotSuite.waterfall_components_decomposition(var, figsize=(14, 7), **kwargs)[source]#
Create a waterfall plot showing the decomposition of the target into its components.
This plot visualizes how different model components (channels, controls, intercept, seasonality, etc.) contribute to the overall prediction. Each component is shown as a horizontal bar with its contribution value and percentage.
- Parameters:
- var
listofstr List of contribution variable names from the posterior to include in the plot. Example: [“intercept_contribution_original_scale”,
“channel_contribution_original_scale”, “control_contribution_original_scale”]
- original_scalebool, default
True If True, plot contributions in the original scale of the target. Typically you’ll want to use variables ending with “_original_scale”.
- figsize
tupleofint, default (14, 7) The size of the figure in inches (width, height).
- **kwargs
Additional keyword arguments passed to matplotlib’s
subplotsfunction.
- var
- Returns:
- fig
matplotlib.figure.Figure The Figure object containing the plot.
- ax
matplotlib.axes.Axes The Axes object with the waterfall plot.
- fig
- Raises:
ValueErrorIf no posterior data is found in idata. If none of the requested variables are present in idata.posterior.
Examples
Create a waterfall plot with contribution variables:
fig, ax = mmm.plot.waterfall_components_decomposition( var=[ "intercept_contribution_original_scale", "channel_contribution_original_scale", "control_contribution_original_scale", ] )
With custom figure size:
fig, ax = mmm.plot.waterfall_components_decomposition( var=["channel_contribution", "intercept_contribution"], original_scale=False, figsize=(16, 8), )