arviz.InferenceData.__init__#
- InferenceData.__init__(attrs=None, warn_on_custom_groups=False, **kwargs)[source]#
Initialize InferenceData object from keyword xarray datasets.
- Parameters:
- attrs
dict
sets global attribute for InferenceData object.
- warn_on_custom_groupsbool, default
False
Emit a warning when custom groups are present in the InferenceData. “custom group” means any group whose name isn’t defined in InferenceData schema specification
- kwargs
Keyword arguments of xarray datasets
- attrs
Examples
Initiate an InferenceData object from scratch, not recommended. InferenceData objects should be initialized using
from_xyz
methods, see Data for more details.In [1]: import arviz as az ...: import numpy as np ...: import xarray as xr ...: dataset = xr.Dataset( ...: { ...: "a": (["chain", "draw", "a_dim"], np.random.normal(size=(4, 100, 3))), ...: "b": (["chain", "draw"], np.random.normal(size=(4, 100))), ...: }, ...: coords={ ...: "chain": (["chain"], np.arange(4)), ...: "draw": (["draw"], np.arange(100)), ...: "a_dim": (["a_dim"], ["x", "y", "z"]), ...: } ...: ) ...: idata = az.InferenceData(posterior=dataset, prior=dataset) ...: idata ...: Out[1]: Inference data with groups: > posterior > prior
We have created an
InferenceData
object with two groups. Now we can check its contents:In [2]: idata.posterior Out[2]: <xarray.Dataset> Size: 14kB Dimensions: (chain: 4, draw: 100, a_dim: 3) Coordinates: * chain (chain) int64 32B 0 1 2 3 * draw (draw) int64 800B 0 1 2 3 4 5 6 7 8 ... 91 92 93 94 95 96 97 98 99 * a_dim (a_dim) <U1 12B 'x' 'y' 'z' Data variables: a (chain, draw, a_dim) float64 10kB -0.9241 0.7448 ... -2.124 -0.3823 b (chain, draw) float64 3kB -0.804 0.173 1.669 ... 1.007 -1.641