How to save my trace in the system?

I generally recommend using

    ...
    idata = pm.sample(...
trace = idata.posterior  # optionally add .stack(sample=("chain", "draw"))

trace is then an xarray.Dataset which has a lot of features, you can select variables with ["var-name"], compute means, quantiles, plot the variables…

Here are some docs that showcase InferenceData capabilities:

2 Likes