arviz.InferenceData.extend#
- InferenceData.extend(other, join='left')[source]#
Extend InferenceData with groups from another InferenceData.
- Parameters:
- other
InferenceData
InferenceData to be added
- join{‘left’, ‘right’}, default ‘left’
Defines how the two decide which group to keep when the same group is present in both objects. ‘left’ will discard the group in
other
whereas ‘right’ will keep the group inother
and discard the one inself
.
- other
See also
add_groups
Add new groups to InferenceData object.
concat
Concatenate InferenceData objects.
Examples
Take two InferenceData objects, and extend the first with the groups it doesn’t have but are present in the 2nd InferenceData object.
First InferenceData:
import arviz as az idata = az.load_arviz_data("radon")
Second InferenceData:
other_idata = az.load_arviz_data("rugby")
Call the
extend
method:idata.extend(other_idata) idata
arviz.InferenceData-
<xarray.Dataset> Size: 4MB Dimensions: (chain: 4, draw: 500, g_coef: 2, County: 85) Coordinates: * chain (chain) int64 32B 0 1 2 3 * draw (draw) int64 4kB 0 1 2 3 4 5 6 7 ... 493 494 495 496 497 498 499 * g_coef (g_coef) <U9 72B 'intercept' 'slope' * County (County) <U17 6kB 'AITKIN' 'ANOKA' ... 'WRIGHT' 'YELLOW MEDICINE' Data variables: g (chain, draw, g_coef) float64 32kB ... za_county (chain, draw, County) float64 1MB ... b (chain, draw) float64 16kB ... sigma_a (chain, draw) float64 16kB ... a (chain, draw, County) float64 1MB ... a_county (chain, draw, County) float64 1MB ... sigma (chain, draw) float64 16kB ... Attributes: created_at: 2020-07-24T18:15:12.191355 arviz_version: 0.9.0 inference_library: pymc3 inference_library_version: 3.9.2 sampling_time: 18.096983432769775 tuning_steps: 1000
-
<xarray.Dataset> Size: 15MB Dimensions: (chain: 4, draw: 500, obs_id: 919) Coordinates: * chain (chain) int64 32B 0 1 2 3 * draw (draw) int64 4kB 0 1 2 3 4 5 6 7 ... 493 494 495 496 497 498 499 * obs_id (obs_id) int64 7kB 0 1 2 3 4 5 6 7 ... 912 913 914 915 916 917 918 Data variables: y (chain, draw, obs_id) float64 15MB ... Attributes: created_at: 2020-07-24T18:15:12.449843 arviz_version: 0.9.0 inference_library: pymc3 inference_library_version: 3.9.2
-
<xarray.Dataset> Size: 15MB Dimensions: (chain: 4, draw: 500, obs_id: 919) Coordinates: * chain (chain) int64 32B 0 1 2 3 * draw (draw) int64 4kB 0 1 2 3 4 5 6 7 ... 493 494 495 496 497 498 499 * obs_id (obs_id) int64 7kB 0 1 2 3 4 5 6 7 ... 912 913 914 915 916 917 918 Data variables: y (chain, draw, obs_id) float64 15MB ... Attributes: created_at: 2020-07-24T18:15:12.448264 arviz_version: 0.9.0 inference_library: pymc3 inference_library_version: 3.9.2
-
<xarray.Dataset> Size: 260kB Dimensions: (chain: 4, draw: 500, team: 6) Coordinates: * chain (chain) int64 32B 0 1 2 3 * draw (draw) int64 4kB 0 1 2 3 4 5 6 7 ... 493 494 495 496 497 498 499 * team (team) <U8 192B 'Wales' 'France' 'Ireland' ... 'Italy' 'England' Data variables: home (chain, draw) float64 16kB ... sd_att (chain, draw) float64 16kB ... sd_def (chain, draw) float64 16kB ... intercept (chain, draw) float64 16kB ... atts_star (chain, draw, team) float64 96kB ... defs_star (chain, draw, team) float64 96kB ... Attributes: created_at: 2024-03-06T20:46:24.377610 arviz_version: 0.17.0 inference_library: pymc inference_library_version: 5.10.4+7.g34d2a5d9
-
<xarray.Dataset> Size: 150kB Dimensions: (chain: 4, draw: 500) Coordinates: * chain (chain) int64 32B 0 1 2 3 * draw (draw) int64 4kB 0 1 2 3 4 5 6 ... 494 495 496 497 498 499 Data variables: step_size_bar (chain, draw) float64 16kB ... diverging (chain, draw) bool 2kB ... energy (chain, draw) float64 16kB ... tree_size (chain, draw) float64 16kB ... mean_tree_accept (chain, draw) float64 16kB ... step_size (chain, draw) float64 16kB ... depth (chain, draw) int64 16kB ... energy_error (chain, draw) float64 16kB ... lp (chain, draw) float64 16kB ... max_energy_error (chain, draw) float64 16kB ... Attributes: created_at: 2020-07-24T18:15:12.197697 arviz_version: 0.9.0 inference_library: pymc3 inference_library_version: 3.9.2 sampling_time: 18.096983432769775 tuning_steps: 1000
-
<xarray.Dataset> Size: 1MB Dimensions: (chain: 1, draw: 500, County: 85, g_coef: 2) Coordinates: * chain (chain) int64 8B 0 * draw (draw) int64 4kB 0 1 2 3 4 5 6 ... 494 495 496 497 498 499 * County (County) <U17 6kB 'AITKIN' 'ANOKA' ... 'YELLOW MEDICINE' * g_coef (g_coef) <U9 72B 'intercept' 'slope' Data variables: a_county (chain, draw, County) float64 340kB ... sigma_log__ (chain, draw) float64 4kB ... sigma_a (chain, draw) float64 4kB ... a (chain, draw, County) float64 340kB ... b (chain, draw) float64 4kB ... za_county (chain, draw, County) float64 340kB ... sigma (chain, draw) float64 4kB ... g (chain, draw, g_coef) float64 8kB ... sigma_a_log__ (chain, draw) float64 4kB ... Attributes: created_at: 2020-07-24T18:15:12.454586 arviz_version: 0.9.0 inference_library: pymc3 inference_library_version: 3.9.2
-
<xarray.Dataset> Size: 4MB Dimensions: (chain: 1, draw: 500, obs_id: 919) Coordinates: * chain (chain) int64 8B 0 * draw (draw) int64 4kB 0 1 2 3 4 5 6 7 ... 493 494 495 496 497 498 499 * obs_id (obs_id) int64 7kB 0 1 2 3 4 5 6 7 ... 912 913 914 915 916 917 918 Data variables: y (chain, draw, obs_id) float64 4MB ... Attributes: created_at: 2020-07-24T18:15:12.457652 arviz_version: 0.9.0 inference_library: pymc3 inference_library_version: 3.9.2
-
<xarray.Dataset> Size: 15kB Dimensions: (obs_id: 919) Coordinates: * obs_id (obs_id) int64 7kB 0 1 2 3 4 5 6 7 ... 912 913 914 915 916 917 918 Data variables: y (obs_id) float64 7kB ... Attributes: created_at: 2020-07-24T18:15:12.458415 arviz_version: 0.9.0 inference_library: pymc3 inference_library_version: 3.9.2
-
<xarray.Dataset> Size: 21kB Dimensions: (obs_id: 919, County: 85) Coordinates: * obs_id (obs_id) int64 7kB 0 1 2 3 4 5 6 ... 912 913 914 915 916 917 918 * County (County) <U17 6kB 'AITKIN' 'ANOKA' ... 'YELLOW MEDICINE' Data variables: floor_idx (obs_id) int32 4kB ... county_idx (obs_id) int32 4kB ... uranium (County) float64 680B ... Attributes: created_at: 2020-07-24T18:15:12.459832 arviz_version: 0.9.0 inference_library: pymc3 inference_library_version: 3.9.2
-
<xarray.Dataset> Size: 36kB Dimensions: (chain: 4, draw: 500) Coordinates: * chain (chain) int64 32B 0 1 2 3 * draw (draw) int64 4kB 0 1 2 3 4 5 6 7 ... 493 494 495 496 497 498 499 Data variables: sd_att (chain, draw) float64 16kB ... sd_def (chain, draw) float64 16kB ... Attributes: sd_att: pymc.logprob.transforms.LogTransform sd_def: pymc.logprob.transforms.LogTransform
See how now the first InferenceData has more groups, with the data from the second one, but the groups it originally had have not been modified, even if also present in the second InferenceData.