How does one pull the posterior samples out of the trace and make a data frame?

Hello. How does one pull all of the posterior samples out of the trace element and place them in a data frame?

Hello,

If you want to extract the samples for a variable called y from a run of the posterior_predictive, you can adapt the following code:

ppc = pm.sample_posterior_predictive(trace, samples=500, model=model)
samples_from_posterior = np.asarray(ppc['y'])

There is a function to turn the trace into a dataframe:

pm.trace_to_dataframe(trace)
2 Likes