Get predictions from a model using the MAP values instead of sampling the posterior

reading the documentation of the sample_posterior_predictive method I found this

pymc.sample_posterior_predictive(trace, …)[source]

Generate posterior predictive samples from a model given a trace.
parameters:
trace backend, list, xarray.Dataset, arviz.InferenceData, or MultiTrace

Trace generated from MCMC sampling, or a list of dicts (eg. points or from find_MAP()), or xarray.Dataset (eg. InferenceData.posterior or InferenceData.prior)

so yes, basically you just need to use the MAP values when doing the prediction, changing the trace parameter from the posterior sample:

trace = pm.sample(draws=draws, ...)
post_idata = pm.sample_posterior_predictive(trace, ...)

to a wrapped map list [map]

map = pm.find_MAP()
post_idata = pm.sample_posterior_predictive([map], ...)

that was all

2 Likes