MMMPlotlyFactory.saturation_curves#

MMMPlotlyFactory.saturation_curves(hdi_prob=None, hdi_opacity=0.2, max_value=1.0, num_points=100, num_samples=500, random_state=None, auto_facet=True, single_dim_facet='col', original_scale=True, **plotly_kwargs)[source]#

Plot saturation curves by channel.

Creates an interactive Plotly line chart showing saturation response curves for each channel, with optional HDI uncertainty bands and faceting for multi-dimensional models.

Parameters:
hdi_probfloat or None, optional

HDI probability for uncertainty bands. If None (default), no bands.

hdi_opacityfloat, default 0.2

Opacity for HDI band fill (0-1).

max_valuefloat, default 1.0

Maximum value for curve x-axis (in scaled space)

num_pointsint, default 100

Number of points along the x-axis to evaluate curves at

num_samplesint or None, optional

Number of posterior samples to use for generating curves. By default 500. Using fewer samples speeds up computation and reduces memory usage while still capturing posterior uncertainty. If None, all posterior samples are used without subsampling.

random_stateint, np.random.Generator, or None, optional

Random state for reproducible subsampling. Can be an integer seed, a numpy Generator instance, or None for non-reproducible sampling. Only used when num_samples is not None and less than total available samples.

auto_facetbool, default True

Automatically detect and apply faceting for custom dimensions.

single_dim_facet{“col”, “row”}, default “col”

When auto_facet is enabled and there is exactly one custom dimension, this controls whether it is applied as facet_col or facet_row.

original_scalebool, default True

Whether to plot x-axis in original scale. If True (default), the x-axis values are multiplied by the channel scale factor to show spend in original units (e.g., dollars). If False, x-axis shows scaled values.

**plotly_kwargs

Additional Plotly Express arguments including: - title: Figure title (default: “Saturation Curves”) - facet_row: Column for row facets - facet_col: Column for column facets - facet_col_wrap: Max columns before wrapping

Returns:
go.Figure

Interactive Plotly figure

Examples

>>> # Basic saturation curves
>>> fig = mmm.plot_interactive.saturation_curves()
>>> fig.show()
>>> # With faceting by country
>>> fig = mmm.plot_interactive.saturation_curves(
...     facet_col="country", facet_col_wrap=3
... )
>>> fig.show()
>>> # Custom x-axis range
>>> fig = mmm.plot_interactive.saturation_curves(max_value=2.0, num_points=50)
>>> fig.show()