How to retrieve information from inference data?

Poor formatting, but this will sort of get you what you want:

for group in ["prior", "prior_predictive", "observed_data"]:
    print(f"{group}")
    for var in list(model_prior[group].keys()):
        print(f"  {var}: {model_prior[group][var].shape}")

But in general, you would probably not want to do this because there could be a large number of variables in each group. On top of that, you are using shapes rather than the preferred coords/dims that you see when you inspect an individual group (see here and here for more info on using dimensions).

Inspecting model_prior.prior yields:

<xarray.Dataset>
Dimensions:  (chain: 1, draw: 100)
Coordinates:
  * chain    (chain) int64 0
  * draw     (draw) int64 0 1 2 3 4 5 6 7 8 9 ... 90 91 92 93 94 95 96 97 98 99
Data variables:
    p        (chain, draw) float64 5.762e-05 0.4165 0.99 ... 0.3721 0.9852
Attributes:
    created_at:                 2023-03-29T15:06:39.322939
    arviz_version:              0.14.0
    inference_library:          pymc
    inference_library_version:  5.0.0

In particular, this tells you that p has 2 dimensions (chain and draw) and that chain has 1 coordinate and draw has 100. But the fact that you have 2 dimensions and (now) know what those dimensions are typically provides you with much more information than something like p: (1, 100).

1 Like