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
datadict[str] -> ndarray

Data to convert. Keys are variable names.

attrsdict

Json serializable metadata to attach to the dataset, in addition to defaults.

librarymodule

Library used for performing inference. Will be attached to the attrs metadata.

coordsdict[str] -> ndarray

Coordinates for the dataset

dimsdict[str] -> list[str]

Dimensions of each variable. The keys are variable names, values are lists of coordinates.

default_dimslist of str, optional

Passed to numpy_to_data_array()

index_originint, 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.

Returns
xr.Dataset

Examples

dict_to_dataset({‘x’: np.random.randn(4, 100), ‘y’: np.random.rand(4, 100)})