arviz_base.from_dict#

arviz_base.from_dict(data, *, name=None, sample_dims=None, save_warmup=None, index_origin=None, coords=None, dims=None, pred_dims=None, pred_coords=None, check_conventions=True, attrs=None)[source]#

Convert nested dictionary into a DataTree.

It uses dict_to_dataset to convert a nested dictionary to a DataTree using ArviZ conventions.

Parameters:
datadict of {strdict of {hashable: array_like}}

Dictionary to convert to DataTree. It must be a nested dictionary. The keys of the outer dictionary are group names, the values of the outer dictionary must be dictionaries themselves with the variables that should be stored in that group. These inner dictionaries are passed to dict_to_dataset.

Depending on the group name, the arguments used when calling dict_to_dataset can take different arguments from their defaults:

  • If data is a substring of the group name, sample_dims will be set to an empty list: []

  • If predictions is a substring of the group name, pred_coords and pred_dims will be passed to dict_to_dataset as coords and dims.

  • If log_likelihood is a substring of the group name, skip_event_dims is set to True.

namestr, optional

Name of the DataTree root node. This is used as the DataTree name by ArviZ.

sample_dimsiterable of hashable, optional

Dimensions that should be assumed to be present in _all_ variables. If missing, they will be added as the dimensions corresponding to the leading axis.

save_warmupbool, optional

Save warmup iterations DataTree. If not defined, use default defined by the rcParams. When set to False, groups in data that have warmup as substring will be ignored.

index_originint, optional

Start value to use default integer ids for dimensions without provided coordinate values. Defaults to data.index_origin.

coordsdict of {hashablelist}, optional

A dictionary containing the values that are used as index. The key is the name of the dimension, the values are the index values.

dimsdict of {hashablelist of hashable}, optional

A mapping from variable names to a list of dimension names for the variable.

pred_dimsdict of {strlist of str}, optional

A mapping from variables to a list of coordinate names for predictions.

pred_coordsdict of {strlist}, optional

A mapping from variables to a list of coordinate values for predictions.

check_conventionsbool, default True

Check some ArviZ conventions on dimension meaning.

attrsdict of {strdict}, optional

A dictionary containing attributes for different groups. Its keys should match keys in data, with the exception of “/” which is used to set global attributes.

Returns:
datatree.DataTree