arviz.InferenceData.isel — ArviZ dev documentation (original) (raw)

InferenceData.isel(groups=None, filter_groups=None, inplace=False, **kwargs)[source]#

Perform an xarray selection on all groups.

Loops groups to perform Dataset.isel(key=item) for every kwarg if key is a dimension of the dataset. One example could be performing a burn in cut on the InferenceData object or discarding a chain. The selection is performed on all relevant groups (like posterior, prior, sample stats) while non relevant groups like observed data are omitted. See xarray.Dataset.isel()

Parameters:

groupsstr or list of str, optional

Groups where the selection is to be applied. Can either be group names or metagroup names.

filter_groups{None, “like”, “regex”}, optional

If None (default), interpret groups as the real group or metagroup names. If “like”, interpret groups as substrings of the real group or metagroup names. If “regex”, interpret groups as regular expressions on the real group or metagroup names. A la pandas.filter.

inplacebool, optional

If True, modify the InferenceData object inplace, otherwise, return the modified copy.

kwargsdict, optional

It must be accepted by xarray.Dataset.isel().

Returns:

InferenceData

A new InferenceData object by default. When inplace==True perform selection in-place and return None

See also

xarray.Dataset.isel

Returns a new dataset with each array indexed along the specified dimension(s).

sel

Returns a new dataset with each array indexed by tick labels along the specified dimension(s).

Examples

Use isel to discard one chain of the InferenceData object. We first check the dimensions of the original object:

import arviz as az idata = az.load_arviz_data("centered_eight") idata

In order to remove the third chain:

idata_subset = idata.isel(chain=[0, 1, 3], groups="posterior_groups") idata_subset

You can expand the groups and coords in each group to see how now only the chains 0, 1 and 3 are present.