MMMPlotSuite.uplift_curve#

MMMPlotSuite.uplift_curve(hdi_prob=0.94, ax=None, aggregation=None, subplot_kwargs=None, *, plot_kwargs=None, ylabel='Uplift', xlabel='Sweep', title='Uplift curve', add_figure_title=True)[source]#

Plot precomputed uplift curves stored under idata.sensitivity_analysis['uplift_curve'].

Parameters:
hdi_probfloat, default 0.94

HDI probability mass.

axplt.Axes, optional

The axis to plot on.

aggregationdict, optional

Aggregation to apply to the data. E.g., {“sum”: (“channel”,)} to sum over the channel dimension.

subplot_kwargsdict, optional

Additional subplot configuration forwarded to sensitivity_analysis().

plot_kwargsdict, optional

Keyword arguments forwarded to the underlying line plot. If not provided, defaults are used by sensitivity_analysis() (e.g., color “C0”).

ylabelstr, optional

Y-axis label. Defaults to “Uplift”.

xlabelstr, optional

X-axis label. Defaults to “Sweep”.

titlestr, optional

Figure-level title to add when add_figure_title=True. Defaults to “Uplift curve”.

add_figure_titlebool, optional

Whether to add a figure-level title. Defaults to True.

Examples

Persist uplift curve and plot:

from pymc_marketing.mmm.sensitivity_analysis import SensitivityAnalysis

sweeps = np.linspace(0.5, 1.5, 11)
sa = SensitivityAnalysis(mmm.model, mmm.idata)
results = sa.run_sweep(
    var_input="channel_data",
    sweep_values=sweeps,
    var_names="channel_contribution",
    sweep_type="multiplicative",
)
uplift = sa.compute_uplift_curve_respect_to_base(
    results, ref=1.0, extend_idata=True
)
_ = mmm.plot.uplift_curve(hdi_prob=0.9)