arviz.dict_to_dataset#
- arviz.dict_to_dataset(data, *, attrs=None, library=None, coords=None, dims=None, default_dims=None, index_origin=None, skip_event_dims=None)[source]#
Convert a dictionary of numpy arrays to an xarray.Dataset.
- Parameters
- data
dict
[str
] ->ndarray
Data to convert. Keys are variable names.
- attrs
dict
Json serializable metadata to attach to the dataset, in addition to defaults.
- library
module
Library used for performing inference. Will be attached to the attrs metadata.
- coords
dict
[str
] ->ndarray
Coordinates for the dataset
- dims
dict
[str
] ->list
[str
] Dimensions of each variable. The keys are variable names, values are lists of coordinates.
- default_dims
list
ofstr
, optional Passed to
numpy_to_data_array()
- index_origin
int
, optional Passed to
numpy_to_data_array()
- skip_event_dimsbool
If True, cut extra dims whenever present to match the shape of the data. Necessary for PPLs which have the same name in both observed data and log likelihood groups, to account for their different shapes when observations are multivariate.
- data
- Returns
xr.Dataset
Examples
dict_to_dataset({‘x’: np.random.randn(4, 100), ‘y’: np.random.rand(4, 100)})