arviz 0.23.3__py3-none-any.whl → 1.0.0rc0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- arviz/__init__.py +52 -367
- arviz-1.0.0rc0.dist-info/METADATA +182 -0
- arviz-1.0.0rc0.dist-info/RECORD +5 -0
- {arviz-0.23.3.dist-info → arviz-1.0.0rc0.dist-info}/WHEEL +1 -2
- {arviz-0.23.3.dist-info → arviz-1.0.0rc0.dist-info}/licenses/LICENSE +0 -1
- arviz/data/__init__.py +0 -55
- arviz/data/base.py +0 -596
- arviz/data/converters.py +0 -203
- arviz/data/datasets.py +0 -161
- arviz/data/example_data/code/radon/radon.json +0 -326
- arviz/data/example_data/data/centered_eight.nc +0 -0
- arviz/data/example_data/data/non_centered_eight.nc +0 -0
- arviz/data/example_data/data_local.json +0 -12
- arviz/data/example_data/data_remote.json +0 -58
- arviz/data/inference_data.py +0 -2386
- arviz/data/io_beanmachine.py +0 -112
- arviz/data/io_cmdstan.py +0 -1036
- arviz/data/io_cmdstanpy.py +0 -1233
- arviz/data/io_datatree.py +0 -23
- arviz/data/io_dict.py +0 -462
- arviz/data/io_emcee.py +0 -317
- arviz/data/io_json.py +0 -54
- arviz/data/io_netcdf.py +0 -68
- arviz/data/io_numpyro.py +0 -497
- arviz/data/io_pyjags.py +0 -378
- arviz/data/io_pyro.py +0 -333
- arviz/data/io_pystan.py +0 -1095
- arviz/data/io_zarr.py +0 -46
- arviz/data/utils.py +0 -139
- arviz/labels.py +0 -210
- arviz/plots/__init__.py +0 -61
- arviz/plots/autocorrplot.py +0 -171
- arviz/plots/backends/__init__.py +0 -223
- arviz/plots/backends/bokeh/__init__.py +0 -166
- arviz/plots/backends/bokeh/autocorrplot.py +0 -101
- arviz/plots/backends/bokeh/bfplot.py +0 -23
- arviz/plots/backends/bokeh/bpvplot.py +0 -193
- arviz/plots/backends/bokeh/compareplot.py +0 -167
- arviz/plots/backends/bokeh/densityplot.py +0 -239
- arviz/plots/backends/bokeh/distcomparisonplot.py +0 -23
- arviz/plots/backends/bokeh/distplot.py +0 -183
- arviz/plots/backends/bokeh/dotplot.py +0 -113
- arviz/plots/backends/bokeh/ecdfplot.py +0 -73
- arviz/plots/backends/bokeh/elpdplot.py +0 -203
- arviz/plots/backends/bokeh/energyplot.py +0 -155
- arviz/plots/backends/bokeh/essplot.py +0 -176
- arviz/plots/backends/bokeh/forestplot.py +0 -772
- arviz/plots/backends/bokeh/hdiplot.py +0 -54
- arviz/plots/backends/bokeh/kdeplot.py +0 -268
- arviz/plots/backends/bokeh/khatplot.py +0 -163
- arviz/plots/backends/bokeh/lmplot.py +0 -185
- arviz/plots/backends/bokeh/loopitplot.py +0 -211
- arviz/plots/backends/bokeh/mcseplot.py +0 -184
- arviz/plots/backends/bokeh/pairplot.py +0 -328
- arviz/plots/backends/bokeh/parallelplot.py +0 -81
- arviz/plots/backends/bokeh/posteriorplot.py +0 -324
- arviz/plots/backends/bokeh/ppcplot.py +0 -379
- arviz/plots/backends/bokeh/rankplot.py +0 -149
- arviz/plots/backends/bokeh/separationplot.py +0 -107
- arviz/plots/backends/bokeh/traceplot.py +0 -436
- arviz/plots/backends/bokeh/violinplot.py +0 -164
- arviz/plots/backends/matplotlib/__init__.py +0 -124
- arviz/plots/backends/matplotlib/autocorrplot.py +0 -72
- arviz/plots/backends/matplotlib/bfplot.py +0 -78
- arviz/plots/backends/matplotlib/bpvplot.py +0 -177
- arviz/plots/backends/matplotlib/compareplot.py +0 -135
- arviz/plots/backends/matplotlib/densityplot.py +0 -194
- arviz/plots/backends/matplotlib/distcomparisonplot.py +0 -119
- arviz/plots/backends/matplotlib/distplot.py +0 -178
- arviz/plots/backends/matplotlib/dotplot.py +0 -116
- arviz/plots/backends/matplotlib/ecdfplot.py +0 -70
- arviz/plots/backends/matplotlib/elpdplot.py +0 -189
- arviz/plots/backends/matplotlib/energyplot.py +0 -113
- arviz/plots/backends/matplotlib/essplot.py +0 -180
- arviz/plots/backends/matplotlib/forestplot.py +0 -656
- arviz/plots/backends/matplotlib/hdiplot.py +0 -48
- arviz/plots/backends/matplotlib/kdeplot.py +0 -177
- arviz/plots/backends/matplotlib/khatplot.py +0 -241
- arviz/plots/backends/matplotlib/lmplot.py +0 -149
- arviz/plots/backends/matplotlib/loopitplot.py +0 -144
- arviz/plots/backends/matplotlib/mcseplot.py +0 -161
- arviz/plots/backends/matplotlib/pairplot.py +0 -355
- arviz/plots/backends/matplotlib/parallelplot.py +0 -58
- arviz/plots/backends/matplotlib/posteriorplot.py +0 -348
- arviz/plots/backends/matplotlib/ppcplot.py +0 -478
- arviz/plots/backends/matplotlib/rankplot.py +0 -119
- arviz/plots/backends/matplotlib/separationplot.py +0 -97
- arviz/plots/backends/matplotlib/traceplot.py +0 -526
- arviz/plots/backends/matplotlib/tsplot.py +0 -121
- arviz/plots/backends/matplotlib/violinplot.py +0 -148
- arviz/plots/bfplot.py +0 -128
- arviz/plots/bpvplot.py +0 -308
- arviz/plots/compareplot.py +0 -177
- arviz/plots/densityplot.py +0 -284
- arviz/plots/distcomparisonplot.py +0 -197
- arviz/plots/distplot.py +0 -233
- arviz/plots/dotplot.py +0 -233
- arviz/plots/ecdfplot.py +0 -372
- arviz/plots/elpdplot.py +0 -174
- arviz/plots/energyplot.py +0 -147
- arviz/plots/essplot.py +0 -319
- arviz/plots/forestplot.py +0 -304
- arviz/plots/hdiplot.py +0 -211
- arviz/plots/kdeplot.py +0 -357
- arviz/plots/khatplot.py +0 -236
- arviz/plots/lmplot.py +0 -380
- arviz/plots/loopitplot.py +0 -224
- arviz/plots/mcseplot.py +0 -194
- arviz/plots/pairplot.py +0 -281
- arviz/plots/parallelplot.py +0 -204
- arviz/plots/plot_utils.py +0 -599
- arviz/plots/posteriorplot.py +0 -298
- arviz/plots/ppcplot.py +0 -369
- arviz/plots/rankplot.py +0 -232
- arviz/plots/separationplot.py +0 -167
- arviz/plots/styles/arviz-bluish.mplstyle +0 -1
- arviz/plots/styles/arviz-brownish.mplstyle +0 -1
- arviz/plots/styles/arviz-colors.mplstyle +0 -2
- arviz/plots/styles/arviz-cyanish.mplstyle +0 -1
- arviz/plots/styles/arviz-darkgrid.mplstyle +0 -40
- arviz/plots/styles/arviz-doc.mplstyle +0 -88
- arviz/plots/styles/arviz-docgrid.mplstyle +0 -88
- arviz/plots/styles/arviz-grayscale.mplstyle +0 -41
- arviz/plots/styles/arviz-greenish.mplstyle +0 -1
- arviz/plots/styles/arviz-orangish.mplstyle +0 -1
- arviz/plots/styles/arviz-plasmish.mplstyle +0 -1
- arviz/plots/styles/arviz-purplish.mplstyle +0 -1
- arviz/plots/styles/arviz-redish.mplstyle +0 -1
- arviz/plots/styles/arviz-royish.mplstyle +0 -1
- arviz/plots/styles/arviz-viridish.mplstyle +0 -1
- arviz/plots/styles/arviz-white.mplstyle +0 -40
- arviz/plots/styles/arviz-whitegrid.mplstyle +0 -40
- arviz/plots/traceplot.py +0 -273
- arviz/plots/tsplot.py +0 -440
- arviz/plots/violinplot.py +0 -192
- arviz/preview.py +0 -58
- arviz/py.typed +0 -0
- arviz/rcparams.py +0 -606
- arviz/sel_utils.py +0 -223
- arviz/static/css/style.css +0 -340
- arviz/static/html/icons-svg-inline.html +0 -15
- arviz/stats/__init__.py +0 -37
- arviz/stats/density_utils.py +0 -1013
- arviz/stats/diagnostics.py +0 -1013
- arviz/stats/ecdf_utils.py +0 -324
- arviz/stats/stats.py +0 -2422
- arviz/stats/stats_refitting.py +0 -119
- arviz/stats/stats_utils.py +0 -609
- arviz/tests/__init__.py +0 -1
- arviz/tests/base_tests/__init__.py +0 -1
- arviz/tests/base_tests/test_data.py +0 -1679
- arviz/tests/base_tests/test_data_zarr.py +0 -143
- arviz/tests/base_tests/test_diagnostics.py +0 -511
- arviz/tests/base_tests/test_diagnostics_numba.py +0 -87
- arviz/tests/base_tests/test_helpers.py +0 -18
- arviz/tests/base_tests/test_labels.py +0 -69
- arviz/tests/base_tests/test_plot_utils.py +0 -342
- arviz/tests/base_tests/test_plots_bokeh.py +0 -1288
- arviz/tests/base_tests/test_plots_matplotlib.py +0 -2197
- arviz/tests/base_tests/test_rcparams.py +0 -317
- arviz/tests/base_tests/test_stats.py +0 -925
- arviz/tests/base_tests/test_stats_ecdf_utils.py +0 -166
- arviz/tests/base_tests/test_stats_numba.py +0 -45
- arviz/tests/base_tests/test_stats_utils.py +0 -384
- arviz/tests/base_tests/test_utils.py +0 -376
- arviz/tests/base_tests/test_utils_numba.py +0 -87
- arviz/tests/conftest.py +0 -46
- arviz/tests/external_tests/__init__.py +0 -1
- arviz/tests/external_tests/test_data_beanmachine.py +0 -78
- arviz/tests/external_tests/test_data_cmdstan.py +0 -398
- arviz/tests/external_tests/test_data_cmdstanpy.py +0 -496
- arviz/tests/external_tests/test_data_emcee.py +0 -166
- arviz/tests/external_tests/test_data_numpyro.py +0 -434
- arviz/tests/external_tests/test_data_pyjags.py +0 -119
- arviz/tests/external_tests/test_data_pyro.py +0 -260
- arviz/tests/external_tests/test_data_pystan.py +0 -307
- arviz/tests/helpers.py +0 -677
- arviz/utils.py +0 -773
- arviz/wrappers/__init__.py +0 -13
- arviz/wrappers/base.py +0 -236
- arviz/wrappers/wrap_pymc.py +0 -36
- arviz/wrappers/wrap_stan.py +0 -148
- arviz-0.23.3.dist-info/METADATA +0 -264
- arviz-0.23.3.dist-info/RECORD +0 -183
- arviz-0.23.3.dist-info/top_level.txt +0 -1
arviz/data/io_datatree.py
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"""Conversion between InferenceData and DataTree."""
|
|
2
|
-
|
|
3
|
-
from .inference_data import InferenceData
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def to_datatree(data):
|
|
7
|
-
"""Convert InferenceData object to a :class:`~xarray.DataTree`.
|
|
8
|
-
|
|
9
|
-
Parameters
|
|
10
|
-
----------
|
|
11
|
-
data : InferenceData
|
|
12
|
-
"""
|
|
13
|
-
return data.to_datatree()
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def from_datatree(datatree):
|
|
17
|
-
"""Create an InferenceData object from a :class:`~xarray.DataTree`.
|
|
18
|
-
|
|
19
|
-
Parameters
|
|
20
|
-
----------
|
|
21
|
-
datatree : DataTree
|
|
22
|
-
"""
|
|
23
|
-
return InferenceData.from_datatree(datatree)
|
arviz/data/io_dict.py
DELETED
|
@@ -1,462 +0,0 @@
|
|
|
1
|
-
"""Dictionary specific conversion code."""
|
|
2
|
-
|
|
3
|
-
import warnings
|
|
4
|
-
from typing import Optional
|
|
5
|
-
|
|
6
|
-
from ..rcparams import rcParams
|
|
7
|
-
from .base import dict_to_dataset, requires
|
|
8
|
-
from .inference_data import WARMUP_TAG, InferenceData
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
# pylint: disable=too-many-instance-attributes
|
|
12
|
-
class DictConverter:
|
|
13
|
-
"""Encapsulate Dictionary specific logic."""
|
|
14
|
-
|
|
15
|
-
def __init__(
|
|
16
|
-
self,
|
|
17
|
-
*,
|
|
18
|
-
posterior=None,
|
|
19
|
-
posterior_predictive=None,
|
|
20
|
-
predictions=None,
|
|
21
|
-
sample_stats=None,
|
|
22
|
-
log_likelihood=None,
|
|
23
|
-
prior=None,
|
|
24
|
-
prior_predictive=None,
|
|
25
|
-
sample_stats_prior=None,
|
|
26
|
-
observed_data=None,
|
|
27
|
-
constant_data=None,
|
|
28
|
-
predictions_constant_data=None,
|
|
29
|
-
warmup_posterior=None,
|
|
30
|
-
warmup_posterior_predictive=None,
|
|
31
|
-
warmup_predictions=None,
|
|
32
|
-
warmup_log_likelihood=None,
|
|
33
|
-
warmup_sample_stats=None,
|
|
34
|
-
save_warmup=None,
|
|
35
|
-
index_origin=None,
|
|
36
|
-
coords=None,
|
|
37
|
-
dims=None,
|
|
38
|
-
pred_dims=None,
|
|
39
|
-
pred_coords=None,
|
|
40
|
-
attrs=None,
|
|
41
|
-
**kwargs,
|
|
42
|
-
):
|
|
43
|
-
self.posterior = posterior
|
|
44
|
-
self.posterior_predictive = posterior_predictive
|
|
45
|
-
self.predictions = predictions
|
|
46
|
-
self.sample_stats = sample_stats
|
|
47
|
-
self.log_likelihood = log_likelihood
|
|
48
|
-
self.prior = prior
|
|
49
|
-
self.prior_predictive = prior_predictive
|
|
50
|
-
self.sample_stats_prior = sample_stats_prior
|
|
51
|
-
self.observed_data = observed_data
|
|
52
|
-
self.constant_data = constant_data
|
|
53
|
-
self.predictions_constant_data = predictions_constant_data
|
|
54
|
-
self.warmup_posterior = warmup_posterior
|
|
55
|
-
self.warmup_posterior_predictive = warmup_posterior_predictive
|
|
56
|
-
self.warmup_predictions = warmup_predictions
|
|
57
|
-
self.warmup_log_likelihood = warmup_log_likelihood
|
|
58
|
-
self.warmup_sample_stats = warmup_sample_stats
|
|
59
|
-
self.save_warmup = rcParams["data.save_warmup"] if save_warmup is None else save_warmup
|
|
60
|
-
self.coords = (
|
|
61
|
-
coords
|
|
62
|
-
if pred_coords is None
|
|
63
|
-
else pred_coords if coords is None else {**coords, **pred_coords}
|
|
64
|
-
)
|
|
65
|
-
self.index_origin = index_origin
|
|
66
|
-
self.coords = coords
|
|
67
|
-
self.dims = dims
|
|
68
|
-
self.pred_dims = dims if pred_dims is None else pred_dims
|
|
69
|
-
self.attrs = {} if attrs is None else attrs
|
|
70
|
-
self.attrs.pop("created_at", None)
|
|
71
|
-
self.attrs.pop("arviz_version", None)
|
|
72
|
-
self._kwargs = kwargs
|
|
73
|
-
|
|
74
|
-
def _init_dict(self, attr_name):
|
|
75
|
-
dict_or_none = getattr(self, attr_name, {})
|
|
76
|
-
return {} if dict_or_none is None else dict_or_none
|
|
77
|
-
|
|
78
|
-
@requires(["posterior", f"{WARMUP_TAG}posterior"])
|
|
79
|
-
def posterior_to_xarray(self):
|
|
80
|
-
"""Convert posterior samples to xarray."""
|
|
81
|
-
data = self._init_dict("posterior")
|
|
82
|
-
data_warmup = self._init_dict(f"{WARMUP_TAG}posterior")
|
|
83
|
-
if not isinstance(data, dict):
|
|
84
|
-
raise TypeError("DictConverter.posterior is not a dictionary")
|
|
85
|
-
if not isinstance(data_warmup, dict):
|
|
86
|
-
raise TypeError("DictConverter.warmup_posterior is not a dictionary")
|
|
87
|
-
|
|
88
|
-
if "log_likelihood" in data:
|
|
89
|
-
warnings.warn(
|
|
90
|
-
"log_likelihood variable found in posterior group."
|
|
91
|
-
" For stats functions log likelihood data needs to be in log_likelihood group.",
|
|
92
|
-
UserWarning,
|
|
93
|
-
)
|
|
94
|
-
posterior_attrs = self._kwargs.get("posterior_attrs")
|
|
95
|
-
posterior_warmup_attrs = self._kwargs.get("posterior_warmup_attrs")
|
|
96
|
-
return (
|
|
97
|
-
dict_to_dataset(
|
|
98
|
-
data,
|
|
99
|
-
library=None,
|
|
100
|
-
coords=self.coords,
|
|
101
|
-
dims=self.dims,
|
|
102
|
-
attrs=posterior_attrs,
|
|
103
|
-
index_origin=self.index_origin,
|
|
104
|
-
),
|
|
105
|
-
dict_to_dataset(
|
|
106
|
-
data_warmup,
|
|
107
|
-
library=None,
|
|
108
|
-
coords=self.coords,
|
|
109
|
-
dims=self.dims,
|
|
110
|
-
attrs=posterior_warmup_attrs,
|
|
111
|
-
index_origin=self.index_origin,
|
|
112
|
-
),
|
|
113
|
-
)
|
|
114
|
-
|
|
115
|
-
@requires(["sample_stats", f"{WARMUP_TAG}sample_stats"])
|
|
116
|
-
def sample_stats_to_xarray(self):
|
|
117
|
-
"""Convert sample_stats samples to xarray."""
|
|
118
|
-
data = self._init_dict("sample_stats")
|
|
119
|
-
data_warmup = self._init_dict(f"{WARMUP_TAG}sample_stats")
|
|
120
|
-
if not isinstance(data, dict):
|
|
121
|
-
raise TypeError("DictConverter.sample_stats is not a dictionary")
|
|
122
|
-
if not isinstance(data_warmup, dict):
|
|
123
|
-
raise TypeError("DictConverter.warmup_sample_stats is not a dictionary")
|
|
124
|
-
|
|
125
|
-
if "log_likelihood" in data:
|
|
126
|
-
warnings.warn(
|
|
127
|
-
"log_likelihood variable found in sample_stats."
|
|
128
|
-
" Storing log_likelihood data in sample_stats group will be deprecated in "
|
|
129
|
-
"favour of storing them in the log_likelihood group.",
|
|
130
|
-
PendingDeprecationWarning,
|
|
131
|
-
)
|
|
132
|
-
sample_stats_attrs = self._kwargs.get("sample_stats_attrs")
|
|
133
|
-
sample_stats_warmup_attrs = self._kwargs.get("sample_stats_warmup_attrs")
|
|
134
|
-
return (
|
|
135
|
-
dict_to_dataset(
|
|
136
|
-
data,
|
|
137
|
-
library=None,
|
|
138
|
-
coords=self.coords,
|
|
139
|
-
dims=self.dims,
|
|
140
|
-
attrs=sample_stats_attrs,
|
|
141
|
-
index_origin=self.index_origin,
|
|
142
|
-
),
|
|
143
|
-
dict_to_dataset(
|
|
144
|
-
data_warmup,
|
|
145
|
-
library=None,
|
|
146
|
-
coords=self.coords,
|
|
147
|
-
dims=self.dims,
|
|
148
|
-
attrs=sample_stats_warmup_attrs,
|
|
149
|
-
index_origin=self.index_origin,
|
|
150
|
-
),
|
|
151
|
-
)
|
|
152
|
-
|
|
153
|
-
@requires(["log_likelihood", f"{WARMUP_TAG}log_likelihood"])
|
|
154
|
-
def log_likelihood_to_xarray(self):
|
|
155
|
-
"""Convert log_likelihood samples to xarray."""
|
|
156
|
-
data = self._init_dict("log_likelihood")
|
|
157
|
-
data_warmup = self._init_dict(f"{WARMUP_TAG}log_likelihood")
|
|
158
|
-
if not isinstance(data, dict):
|
|
159
|
-
raise TypeError("DictConverter.log_likelihood is not a dictionary")
|
|
160
|
-
if not isinstance(data_warmup, dict):
|
|
161
|
-
raise TypeError("DictConverter.warmup_log_likelihood is not a dictionary")
|
|
162
|
-
log_likelihood_attrs = self._kwargs.get("log_likelihood_attrs")
|
|
163
|
-
log_likelihood_warmup_attrs = self._kwargs.get("log_likelihood_warmup_attrs")
|
|
164
|
-
return (
|
|
165
|
-
dict_to_dataset(
|
|
166
|
-
data,
|
|
167
|
-
library=None,
|
|
168
|
-
coords=self.coords,
|
|
169
|
-
dims=self.dims,
|
|
170
|
-
attrs=log_likelihood_attrs,
|
|
171
|
-
index_origin=self.index_origin,
|
|
172
|
-
skip_event_dims=True,
|
|
173
|
-
),
|
|
174
|
-
dict_to_dataset(
|
|
175
|
-
data_warmup,
|
|
176
|
-
library=None,
|
|
177
|
-
coords=self.coords,
|
|
178
|
-
dims=self.dims,
|
|
179
|
-
attrs=log_likelihood_warmup_attrs,
|
|
180
|
-
index_origin=self.index_origin,
|
|
181
|
-
skip_event_dims=True,
|
|
182
|
-
),
|
|
183
|
-
)
|
|
184
|
-
|
|
185
|
-
@requires(["posterior_predictive", f"{WARMUP_TAG}posterior_predictive"])
|
|
186
|
-
def posterior_predictive_to_xarray(self):
|
|
187
|
-
"""Convert posterior_predictive samples to xarray."""
|
|
188
|
-
data = self._init_dict("posterior_predictive")
|
|
189
|
-
data_warmup = self._init_dict(f"{WARMUP_TAG}posterior_predictive")
|
|
190
|
-
if not isinstance(data, dict):
|
|
191
|
-
raise TypeError("DictConverter.posterior_predictive is not a dictionary")
|
|
192
|
-
if not isinstance(data_warmup, dict):
|
|
193
|
-
raise TypeError("DictConverter.warmup_posterior_predictive is not a dictionary")
|
|
194
|
-
posterior_predictive_attrs = self._kwargs.get("posterior_predictive_attrs")
|
|
195
|
-
posterior_predictive_warmup_attrs = self._kwargs.get("posterior_predictive_warmup_attrs")
|
|
196
|
-
return (
|
|
197
|
-
dict_to_dataset(
|
|
198
|
-
data,
|
|
199
|
-
library=None,
|
|
200
|
-
coords=self.coords,
|
|
201
|
-
dims=self.dims,
|
|
202
|
-
attrs=posterior_predictive_attrs,
|
|
203
|
-
index_origin=self.index_origin,
|
|
204
|
-
),
|
|
205
|
-
dict_to_dataset(
|
|
206
|
-
data_warmup,
|
|
207
|
-
library=None,
|
|
208
|
-
coords=self.coords,
|
|
209
|
-
dims=self.dims,
|
|
210
|
-
attrs=posterior_predictive_warmup_attrs,
|
|
211
|
-
index_origin=self.index_origin,
|
|
212
|
-
),
|
|
213
|
-
)
|
|
214
|
-
|
|
215
|
-
@requires(["predictions", f"{WARMUP_TAG}predictions"])
|
|
216
|
-
def predictions_to_xarray(self):
|
|
217
|
-
"""Convert predictions to xarray."""
|
|
218
|
-
data = self._init_dict("predictions")
|
|
219
|
-
data_warmup = self._init_dict(f"{WARMUP_TAG}predictions")
|
|
220
|
-
if not isinstance(data, dict):
|
|
221
|
-
raise TypeError("DictConverter.predictions is not a dictionary")
|
|
222
|
-
if not isinstance(data_warmup, dict):
|
|
223
|
-
raise TypeError("DictConverter.warmup_predictions is not a dictionary")
|
|
224
|
-
predictions_attrs = self._kwargs.get("predictions_attrs")
|
|
225
|
-
predictions_warmup_attrs = self._kwargs.get("predictions_warmup_attrs")
|
|
226
|
-
return (
|
|
227
|
-
dict_to_dataset(
|
|
228
|
-
data,
|
|
229
|
-
library=None,
|
|
230
|
-
coords=self.coords,
|
|
231
|
-
dims=self.pred_dims,
|
|
232
|
-
attrs=predictions_attrs,
|
|
233
|
-
index_origin=self.index_origin,
|
|
234
|
-
),
|
|
235
|
-
dict_to_dataset(
|
|
236
|
-
data_warmup,
|
|
237
|
-
library=None,
|
|
238
|
-
coords=self.coords,
|
|
239
|
-
dims=self.pred_dims,
|
|
240
|
-
attrs=predictions_warmup_attrs,
|
|
241
|
-
index_origin=self.index_origin,
|
|
242
|
-
),
|
|
243
|
-
)
|
|
244
|
-
|
|
245
|
-
@requires("prior")
|
|
246
|
-
def prior_to_xarray(self):
|
|
247
|
-
"""Convert prior samples to xarray."""
|
|
248
|
-
data = self.prior
|
|
249
|
-
if not isinstance(data, dict):
|
|
250
|
-
raise TypeError("DictConverter.prior is not a dictionary")
|
|
251
|
-
prior_attrs = self._kwargs.get("prior_attrs")
|
|
252
|
-
return dict_to_dataset(
|
|
253
|
-
data,
|
|
254
|
-
library=None,
|
|
255
|
-
coords=self.coords,
|
|
256
|
-
dims=self.dims,
|
|
257
|
-
attrs=prior_attrs,
|
|
258
|
-
index_origin=self.index_origin,
|
|
259
|
-
)
|
|
260
|
-
|
|
261
|
-
@requires("sample_stats_prior")
|
|
262
|
-
def sample_stats_prior_to_xarray(self):
|
|
263
|
-
"""Convert sample_stats_prior samples to xarray."""
|
|
264
|
-
data = self.sample_stats_prior
|
|
265
|
-
if not isinstance(data, dict):
|
|
266
|
-
raise TypeError("DictConverter.sample_stats_prior is not a dictionary")
|
|
267
|
-
sample_stats_prior_attrs = self._kwargs.get("sample_stats_prior_attrs")
|
|
268
|
-
return dict_to_dataset(
|
|
269
|
-
data,
|
|
270
|
-
library=None,
|
|
271
|
-
coords=self.coords,
|
|
272
|
-
dims=self.dims,
|
|
273
|
-
attrs=sample_stats_prior_attrs,
|
|
274
|
-
index_origin=self.index_origin,
|
|
275
|
-
)
|
|
276
|
-
|
|
277
|
-
@requires("prior_predictive")
|
|
278
|
-
def prior_predictive_to_xarray(self):
|
|
279
|
-
"""Convert prior_predictive samples to xarray."""
|
|
280
|
-
data = self.prior_predictive
|
|
281
|
-
if not isinstance(data, dict):
|
|
282
|
-
raise TypeError("DictConverter.prior_predictive is not a dictionary")
|
|
283
|
-
prior_predictive_attrs = self._kwargs.get("prior_predictive_attrs")
|
|
284
|
-
return dict_to_dataset(
|
|
285
|
-
data,
|
|
286
|
-
library=None,
|
|
287
|
-
coords=self.coords,
|
|
288
|
-
dims=self.dims,
|
|
289
|
-
attrs=prior_predictive_attrs,
|
|
290
|
-
index_origin=self.index_origin,
|
|
291
|
-
)
|
|
292
|
-
|
|
293
|
-
def data_to_xarray(self, data, group, dims=None):
|
|
294
|
-
"""Convert data to xarray."""
|
|
295
|
-
if not isinstance(data, dict):
|
|
296
|
-
raise TypeError(f"DictConverter.{group} is not a dictionary")
|
|
297
|
-
if dims is None:
|
|
298
|
-
dims = {} if self.dims is None else self.dims
|
|
299
|
-
return dict_to_dataset(
|
|
300
|
-
data,
|
|
301
|
-
library=None,
|
|
302
|
-
coords=self.coords,
|
|
303
|
-
dims=self.dims,
|
|
304
|
-
default_dims=[],
|
|
305
|
-
attrs=self.attrs,
|
|
306
|
-
index_origin=self.index_origin,
|
|
307
|
-
)
|
|
308
|
-
|
|
309
|
-
@requires("observed_data")
|
|
310
|
-
def observed_data_to_xarray(self):
|
|
311
|
-
"""Convert observed_data to xarray."""
|
|
312
|
-
return self.data_to_xarray(self.observed_data, group="observed_data", dims=self.dims)
|
|
313
|
-
|
|
314
|
-
@requires("constant_data")
|
|
315
|
-
def constant_data_to_xarray(self):
|
|
316
|
-
"""Convert constant_data to xarray."""
|
|
317
|
-
return self.data_to_xarray(self.constant_data, group="constant_data")
|
|
318
|
-
|
|
319
|
-
@requires("predictions_constant_data")
|
|
320
|
-
def predictions_constant_data_to_xarray(self):
|
|
321
|
-
"""Convert predictions_constant_data to xarray."""
|
|
322
|
-
return self.data_to_xarray(
|
|
323
|
-
self.predictions_constant_data, group="predictions_constant_data", dims=self.pred_dims
|
|
324
|
-
)
|
|
325
|
-
|
|
326
|
-
def to_inference_data(self):
|
|
327
|
-
"""Convert all available data to an InferenceData object.
|
|
328
|
-
|
|
329
|
-
Note that if groups can not be created, then the InferenceData
|
|
330
|
-
will not have those groups.
|
|
331
|
-
"""
|
|
332
|
-
return InferenceData(
|
|
333
|
-
**{
|
|
334
|
-
"posterior": self.posterior_to_xarray(),
|
|
335
|
-
"sample_stats": self.sample_stats_to_xarray(),
|
|
336
|
-
"log_likelihood": self.log_likelihood_to_xarray(),
|
|
337
|
-
"posterior_predictive": self.posterior_predictive_to_xarray(),
|
|
338
|
-
"predictions": self.predictions_to_xarray(),
|
|
339
|
-
"prior": self.prior_to_xarray(),
|
|
340
|
-
"sample_stats_prior": self.sample_stats_prior_to_xarray(),
|
|
341
|
-
"prior_predictive": self.prior_predictive_to_xarray(),
|
|
342
|
-
"observed_data": self.observed_data_to_xarray(),
|
|
343
|
-
"constant_data": self.constant_data_to_xarray(),
|
|
344
|
-
"predictions_constant_data": self.predictions_constant_data_to_xarray(),
|
|
345
|
-
"save_warmup": self.save_warmup,
|
|
346
|
-
"attrs": self.attrs,
|
|
347
|
-
}
|
|
348
|
-
)
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
# pylint: disable=too-many-instance-attributes
|
|
352
|
-
def from_dict(
|
|
353
|
-
posterior=None,
|
|
354
|
-
*,
|
|
355
|
-
posterior_predictive=None,
|
|
356
|
-
predictions=None,
|
|
357
|
-
sample_stats=None,
|
|
358
|
-
log_likelihood=None,
|
|
359
|
-
prior=None,
|
|
360
|
-
prior_predictive=None,
|
|
361
|
-
sample_stats_prior=None,
|
|
362
|
-
observed_data=None,
|
|
363
|
-
constant_data=None,
|
|
364
|
-
predictions_constant_data=None,
|
|
365
|
-
warmup_posterior=None,
|
|
366
|
-
warmup_posterior_predictive=None,
|
|
367
|
-
warmup_predictions=None,
|
|
368
|
-
warmup_log_likelihood=None,
|
|
369
|
-
warmup_sample_stats=None,
|
|
370
|
-
save_warmup=None,
|
|
371
|
-
index_origin: Optional[int] = None,
|
|
372
|
-
coords=None,
|
|
373
|
-
dims=None,
|
|
374
|
-
pred_dims=None,
|
|
375
|
-
pred_coords=None,
|
|
376
|
-
attrs=None,
|
|
377
|
-
**kwargs,
|
|
378
|
-
):
|
|
379
|
-
"""Convert Dictionary data into an InferenceData object.
|
|
380
|
-
|
|
381
|
-
For a usage example read the
|
|
382
|
-
:ref:`Creating InferenceData section on from_dict <creating_InferenceData>`
|
|
383
|
-
|
|
384
|
-
Parameters
|
|
385
|
-
----------
|
|
386
|
-
posterior : dict, optional
|
|
387
|
-
posterior_predictive : dict, optional
|
|
388
|
-
predictions: dict, optional
|
|
389
|
-
sample_stats : dict, optional
|
|
390
|
-
log_likelihood : dict, optional
|
|
391
|
-
For stats functions, log likelihood data should be stored here.
|
|
392
|
-
prior : dict, optional
|
|
393
|
-
prior_predictive : dict, optional
|
|
394
|
-
observed_data : dict, optional
|
|
395
|
-
constant_data : dict, optional
|
|
396
|
-
predictions_constant_data: dict, optional
|
|
397
|
-
warmup_posterior : dict, optional
|
|
398
|
-
warmup_posterior_predictive : dict, optional
|
|
399
|
-
warmup_predictions : dict, optional
|
|
400
|
-
warmup_log_likelihood : dict, optional
|
|
401
|
-
warmup_sample_stats : dict, optional
|
|
402
|
-
save_warmup : bool, optional
|
|
403
|
-
Save warmup iterations InferenceData object. If not defined, use default
|
|
404
|
-
defined by the rcParams.
|
|
405
|
-
index_origin : int, optional
|
|
406
|
-
coords : dict of {str : list}, optional
|
|
407
|
-
A dictionary containing the values that are used as index. The key
|
|
408
|
-
is the name of the dimension, the values are the index values.
|
|
409
|
-
dims : dict of {str : list of str}, optional
|
|
410
|
-
A mapping from variables to a list of coordinate names for the variable.
|
|
411
|
-
pred_dims : dict of {str : list of str}, optional
|
|
412
|
-
A mapping from variables to a list of coordinate names for predictions.
|
|
413
|
-
pred_coords : dict of {str : list}, optional
|
|
414
|
-
A mapping from variables to a list of coordinate values for predictions.
|
|
415
|
-
attrs : dict, optional
|
|
416
|
-
A dictionary containing attributes for different groups.
|
|
417
|
-
kwargs : dict, optional
|
|
418
|
-
A dictionary containing group attrs. Accepted kwargs are:
|
|
419
|
-
|
|
420
|
-
- posterior_attrs, posterior_warmup_attrs : attrs for posterior group
|
|
421
|
-
- sample_stats_attrs, sample_stats_warmup_attrs : attrs for sample_stats group
|
|
422
|
-
- log_likelihood_attrs, log_likelihood_warmup_attrs : attrs for log_likelihood group
|
|
423
|
-
- posterior_predictive_attrs, posterior_predictive_warmup_attrs : attrs for
|
|
424
|
-
posterior_predictive group
|
|
425
|
-
- predictions_attrs, predictions_warmup_attrs : attrs for predictions group
|
|
426
|
-
- prior_attrs : attrs for prior group
|
|
427
|
-
- sample_stats_prior_attrs : attrs for sample_stats_prior group
|
|
428
|
-
- prior_predictive_attrs : attrs for prior_predictive group
|
|
429
|
-
|
|
430
|
-
Returns
|
|
431
|
-
-------
|
|
432
|
-
InferenceData
|
|
433
|
-
"""
|
|
434
|
-
return DictConverter(
|
|
435
|
-
posterior=posterior,
|
|
436
|
-
posterior_predictive=posterior_predictive,
|
|
437
|
-
predictions=predictions,
|
|
438
|
-
sample_stats=sample_stats,
|
|
439
|
-
log_likelihood=log_likelihood,
|
|
440
|
-
prior=prior,
|
|
441
|
-
prior_predictive=prior_predictive,
|
|
442
|
-
sample_stats_prior=sample_stats_prior,
|
|
443
|
-
observed_data=observed_data,
|
|
444
|
-
constant_data=constant_data,
|
|
445
|
-
predictions_constant_data=predictions_constant_data,
|
|
446
|
-
warmup_posterior=warmup_posterior,
|
|
447
|
-
warmup_posterior_predictive=warmup_posterior_predictive,
|
|
448
|
-
warmup_predictions=warmup_predictions,
|
|
449
|
-
warmup_log_likelihood=warmup_log_likelihood,
|
|
450
|
-
warmup_sample_stats=warmup_sample_stats,
|
|
451
|
-
save_warmup=save_warmup,
|
|
452
|
-
index_origin=index_origin,
|
|
453
|
-
coords=coords,
|
|
454
|
-
dims=dims,
|
|
455
|
-
pred_dims=pred_dims,
|
|
456
|
-
pred_coords=pred_coords,
|
|
457
|
-
attrs=attrs,
|
|
458
|
-
**kwargs,
|
|
459
|
-
).to_inference_data()
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
from_pytree = from_dict
|