src.driver.visualization¶
Visualization and plotting logic for MMM V2 workflow.
This module handles all aspects of result visualization including model diagnostics, posterior plots, and component contributions.
Module Contents¶
- class src.driver.visualization.ResultVisualizer(driver)¶
Handles visualization of MMM results for V2 architecture.
This class manages all plotting and visualization operations for model results, diagnostics, and component analysis.
- generate_all() None¶
Visualizes all results of the model.
- plot_model_structure() graphviz.Digraph¶
Plots the model structure.
- Returns:
Graphviz diagram of model structure.
- Raises:
ValueError – If model not available or PyMC model not found.
- plot_model_trace() matplotlib.figure.Figure¶
Plots the trace of the model parameters.
- Returns:
Matplotlib figure with trace plots.
- Raises:
ValueError – If model not fitted or idata not available.
- plot_components_contributions() matplotlib.figure.Figure¶
Plots the contribution of each model component over time.
- Returns:
Matplotlib figure with component contributions.
- Raises:
ValueError – If model not available.
AttributeError – If model doesn’t have plot_components_contributions method.
- plot_posterior_predictions() matplotlib.figure.Figure¶
Plots the in-sample and out-of-sample posterior predictions.
- Returns:
Matplotlib figure with predictions vs actuals.
- Raises:
ValueError – If model or results directory not available.
- plot_waterfall_components_decomposition(model_to_plot: src.core.base.BaseMMM | None = None, original_scale: bool = True, figsize: Tuple[int, int] = (14, 7), **kwargs: Any) matplotlib.figure.Figure¶
Plots the waterfall decomposition of the model components.
- Parameters:
model_to_plot – Model to plot (defaults to driver’s model).
original_scale – Whether to plot in original scale.
figsize – Figure size tuple.
**kwargs – Additional arguments for plotting.
- Returns:
Matplotlib figure with waterfall decomposition.
- Raises:
ValueError – If no model available.
- plot_posterior_distributions(results_dir_override: str | None = None, filename_prefix: str = 'media_spend_posterior') pandas.DataFrame | None¶
Plots posterior distributions for all media channels.
- Parameters:
results_dir_override – Specific directory to save plots.
filename_prefix – Prefix for the saved plot filename.
- Returns:
DataFrame with statistical summaries of posteriors, or None if plotting fails.
- display_image(image_filename: str) Any | None¶
Displays an image file located in the results directory.
- Parameters:
image_filename – Filename of the image to display.
- Returns:
IPython Image object if available, None otherwise.
- describe_all_media_spend() Any¶
Describes overall media spend.
- Returns:
Description of media spend.
- plot_all_media_spend() Any¶
Plots overall media spend.
- Returns:
Plot of media spend.