Simple question: correct way to save traces?

I personally recommend saving the samples in netCDF format using az.InferenceData, which in addition to the to_netcdf also has a to_zarr method available. And storing the model code instead of pickling the model, you can then recompile it and use it for posterior predictive sampling for example. As far as I know, recompiling the model is the only way to not have any assumptions on the data or data shape with pymc3<4.0 (incoming next major release). Functions that recompile the model based on some input data are generally called model factories, there are some examples in this PyMCon talk: Posterior Predictive Sampling in PyMC3 by Luciano Paz and you can also search for “model factory” to find other related Discourse topics.

As a general endorsed or recommended approach, the only thing I have clear is that it should not involve pm.MultiTrace

2 Likes