plot_expected_purchases_ppc#
- pymc_marketing.clv.plotting.plot_expected_purchases_ppc(model, ppc='posterior', max_purchases=10, samples=1000, random_seed=45, ax=None, plot_type='hist', **kwargs)[source]#
Plot a prior or posterior predictive check for the customer purchase frequency distribution.
ParetoNBDModel,BetaGeoBetaBinomModel,BetaGeoModelandModifiedBetaGeoModelare supported.Adapted from legacy
lifetimeslibrary: CamDavidsonPilon/lifetimes- Parameters:
- model
CLVModel A built CLV model is required for prior predictive checks, and a fitted model for posterior predictive checks.
- ppc
str, optional Type of predictive check to perform. Options are ‘prior’ or ‘posterior’; defaults to ‘posterior’.
- max_purchases
int, optional Cutoff for bars of purchase counts to plot. Only used when
plot_typeis ‘hist’. Default is 10.- samples
int, optional Number of samples to draw for prior predictive checks. This is not used for posterior predictive checks.
- random_seed
int, optional Random seed to fix sampling results
- ax
matplotlib.Axesor sequence ofmatplotlib.Axes, optional A matplotlib Axes instance, or a pair of Axes when
plot_typeis ‘ecdf’. Creates new axes instance(s) by default.- plot_type
str, optional Type of plot to produce. Options are ‘hist’ for a bar chart of estimated vs observed purchase counts, or ‘ecdf’ for an ECDF plot with a 95% simultaneous confidence band and a companion difference plot. Defaults to ‘hist’.
- **kwargs
Additional arguments to pass into the pandas.DataFrame.plot command when
plot_typeis ‘hist’. Whenplot_typeis ‘ecdf’,num_trialsandconfidence_levelcan be passed to control the confidence band.
- model
- Returns:
- axes
matplotlib.AxesSubplot, ortupleoftwomatplotlib.AxesSubplotwhenplot_typeis‘ecdf’
- axes
Notes
The confidence band of the ‘ecdf’ plot assumes a continuous reference CDF, which does not hold for integer purchase counts, so its coverage is only approximately the nominal level. It also assumes that CDF is known rather than estimated, so it warns when the predictive samples behind it are too few relative to the number of customers.