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
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
"""Bokeh loopitplot."""
|
|
2
|
-
|
|
3
|
-
import numpy as np
|
|
4
|
-
from bokeh.models import BoxAnnotation
|
|
5
|
-
from matplotlib.colors import hsv_to_rgb, rgb_to_hsv, to_hex, to_rgb
|
|
6
|
-
from xarray import DataArray
|
|
7
|
-
|
|
8
|
-
from ....stats.density_utils import kde
|
|
9
|
-
from ...plot_utils import _scale_fig_size
|
|
10
|
-
from .. import show_layout
|
|
11
|
-
from . import backend_kwarg_defaults, create_axes_grid
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def plot_loo_pit(
|
|
15
|
-
ax,
|
|
16
|
-
figsize,
|
|
17
|
-
ecdf,
|
|
18
|
-
loo_pit,
|
|
19
|
-
loo_pit_ecdf,
|
|
20
|
-
unif_ecdf,
|
|
21
|
-
p975,
|
|
22
|
-
p025,
|
|
23
|
-
fill_kwargs,
|
|
24
|
-
ecdf_fill,
|
|
25
|
-
use_hdi,
|
|
26
|
-
x_vals,
|
|
27
|
-
hdi_kwargs,
|
|
28
|
-
hdi_odds,
|
|
29
|
-
n_unif,
|
|
30
|
-
unif,
|
|
31
|
-
plot_unif_kwargs,
|
|
32
|
-
loo_pit_kde,
|
|
33
|
-
legend, # pylint: disable=unused-argument
|
|
34
|
-
y_hat,
|
|
35
|
-
y,
|
|
36
|
-
color,
|
|
37
|
-
textsize,
|
|
38
|
-
labeller,
|
|
39
|
-
hdi_prob,
|
|
40
|
-
plot_kwargs,
|
|
41
|
-
backend_kwargs,
|
|
42
|
-
show,
|
|
43
|
-
):
|
|
44
|
-
"""Bokeh loo pit plot."""
|
|
45
|
-
if backend_kwargs is None:
|
|
46
|
-
backend_kwargs = {}
|
|
47
|
-
|
|
48
|
-
backend_kwargs = {
|
|
49
|
-
**backend_kwarg_defaults(),
|
|
50
|
-
**backend_kwargs,
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
(figsize, *_, linewidth, _) = _scale_fig_size(figsize, textsize, 1, 1)
|
|
54
|
-
|
|
55
|
-
if ax is None:
|
|
56
|
-
backend_kwargs.setdefault("x_range", (0, 1))
|
|
57
|
-
ax = create_axes_grid(
|
|
58
|
-
1,
|
|
59
|
-
figsize=figsize,
|
|
60
|
-
squeeze=True,
|
|
61
|
-
backend_kwargs=backend_kwargs,
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
plot_kwargs = {} if plot_kwargs is None else plot_kwargs
|
|
65
|
-
plot_kwargs.setdefault("color", to_hex(color))
|
|
66
|
-
plot_kwargs.setdefault("linewidth", linewidth * 1.4)
|
|
67
|
-
if isinstance(y, str):
|
|
68
|
-
xlabel = y
|
|
69
|
-
elif isinstance(y, DataArray) and y.name is not None:
|
|
70
|
-
xlabel = y.name
|
|
71
|
-
elif isinstance(y_hat, str):
|
|
72
|
-
xlabel = y_hat
|
|
73
|
-
elif isinstance(y_hat, DataArray) and y_hat.name is not None:
|
|
74
|
-
xlabel = y_hat.name
|
|
75
|
-
else:
|
|
76
|
-
xlabel = ""
|
|
77
|
-
label = "LOO-PIT ECDF" if ecdf else "LOO-PIT"
|
|
78
|
-
xlabel = labeller.var_name_to_str(xlabel)
|
|
79
|
-
|
|
80
|
-
plot_kwargs.setdefault("legend_label", label)
|
|
81
|
-
|
|
82
|
-
plot_unif_kwargs = {} if plot_unif_kwargs is None else plot_unif_kwargs
|
|
83
|
-
light_color = rgb_to_hsv(to_rgb(plot_kwargs.get("color")))
|
|
84
|
-
light_color[1] /= 2 # pylint: disable=unsupported-assignment-operation
|
|
85
|
-
light_color[2] += (1 - light_color[2]) / 2 # pylint: disable=unsupported-assignment-operation
|
|
86
|
-
plot_unif_kwargs.setdefault("color", to_hex(hsv_to_rgb(light_color)))
|
|
87
|
-
plot_unif_kwargs.setdefault("alpha", 0.5)
|
|
88
|
-
plot_unif_kwargs.setdefault("linewidth", 0.6 * linewidth)
|
|
89
|
-
|
|
90
|
-
if ecdf:
|
|
91
|
-
n_data_points = loo_pit.size
|
|
92
|
-
plot_kwargs.setdefault("drawstyle", "steps-mid" if n_data_points < 100 else "default")
|
|
93
|
-
plot_unif_kwargs.setdefault("drawstyle", "steps-mid" if n_data_points < 100 else "default")
|
|
94
|
-
|
|
95
|
-
if ecdf_fill:
|
|
96
|
-
if fill_kwargs is None:
|
|
97
|
-
fill_kwargs = {}
|
|
98
|
-
fill_kwargs.setdefault("color", to_hex(hsv_to_rgb(light_color)))
|
|
99
|
-
fill_kwargs.setdefault("alpha", 0.5)
|
|
100
|
-
fill_kwargs.setdefault(
|
|
101
|
-
"step", "mid" if plot_kwargs["drawstyle"] == "steps-mid" else None
|
|
102
|
-
)
|
|
103
|
-
fill_kwargs.setdefault("legend_label", f"{hdi_prob * 100:.3g}% credible interval")
|
|
104
|
-
elif use_hdi:
|
|
105
|
-
if hdi_kwargs is None:
|
|
106
|
-
hdi_kwargs = {}
|
|
107
|
-
hdi_kwargs.setdefault("color", to_hex(hsv_to_rgb(light_color)))
|
|
108
|
-
hdi_kwargs.setdefault("alpha", 0.35)
|
|
109
|
-
|
|
110
|
-
if ecdf:
|
|
111
|
-
if plot_kwargs.get("drawstyle") == "steps-mid":
|
|
112
|
-
ax.step(
|
|
113
|
-
np.hstack((0, loo_pit, 1)),
|
|
114
|
-
np.hstack((0, loo_pit - loo_pit_ecdf, 0)),
|
|
115
|
-
line_color=plot_kwargs.get("color", "black"),
|
|
116
|
-
line_alpha=plot_kwargs.get("alpha", 1.0),
|
|
117
|
-
line_width=plot_kwargs.get("linewidth", 3.0),
|
|
118
|
-
mode="center",
|
|
119
|
-
)
|
|
120
|
-
else:
|
|
121
|
-
ax.line(
|
|
122
|
-
np.hstack((0, loo_pit, 1)),
|
|
123
|
-
np.hstack((0, loo_pit - loo_pit_ecdf, 0)),
|
|
124
|
-
line_color=plot_kwargs.get("color", "black"),
|
|
125
|
-
line_alpha=plot_kwargs.get("alpha", 1.0),
|
|
126
|
-
line_width=plot_kwargs.get("linewidth", 3.0),
|
|
127
|
-
)
|
|
128
|
-
|
|
129
|
-
if ecdf_fill:
|
|
130
|
-
if (
|
|
131
|
-
fill_kwargs.get("drawstyle") == "steps-mid"
|
|
132
|
-
or fill_kwargs.get("drawstyle") != "steps-mid"
|
|
133
|
-
):
|
|
134
|
-
# use step patch when you find out how to do that
|
|
135
|
-
ax.patch(
|
|
136
|
-
np.concatenate((unif_ecdf, unif_ecdf[::-1])),
|
|
137
|
-
np.concatenate((p975 - unif_ecdf, (p025 - unif_ecdf)[::-1])),
|
|
138
|
-
fill_color=fill_kwargs.get("color"),
|
|
139
|
-
fill_alpha=fill_kwargs.get("alpha", 1.0),
|
|
140
|
-
)
|
|
141
|
-
elif fill_kwargs is not None and fill_kwargs.get("drawstyle") == "steps-mid":
|
|
142
|
-
ax.step(
|
|
143
|
-
unif_ecdf,
|
|
144
|
-
p975 - unif_ecdf,
|
|
145
|
-
line_color=plot_unif_kwargs.get("color", "black"),
|
|
146
|
-
line_alpha=plot_unif_kwargs.get("alpha", 1.0),
|
|
147
|
-
line_width=plot_kwargs.get("linewidth", 1.0),
|
|
148
|
-
mode="center",
|
|
149
|
-
)
|
|
150
|
-
ax.step(
|
|
151
|
-
unif_ecdf,
|
|
152
|
-
p025 - unif_ecdf,
|
|
153
|
-
line_color=plot_unif_kwargs.get("color", "black"),
|
|
154
|
-
line_alpha=plot_unif_kwargs.get("alpha", 1.0),
|
|
155
|
-
line_width=plot_unif_kwargs.get("linewidth", 1.0),
|
|
156
|
-
mode="center",
|
|
157
|
-
)
|
|
158
|
-
else:
|
|
159
|
-
ax.line(
|
|
160
|
-
unif_ecdf,
|
|
161
|
-
p975 - unif_ecdf,
|
|
162
|
-
line_color=plot_unif_kwargs.get("color", "black"),
|
|
163
|
-
line_alpha=plot_unif_kwargs.get("alpha", 1.0),
|
|
164
|
-
line_width=plot_unif_kwargs.get("linewidth", 1.0),
|
|
165
|
-
)
|
|
166
|
-
ax.line(
|
|
167
|
-
unif_ecdf,
|
|
168
|
-
p025 - unif_ecdf,
|
|
169
|
-
line_color=plot_unif_kwargs.get("color", "black"),
|
|
170
|
-
line_alpha=plot_unif_kwargs.get("alpha", 1.0),
|
|
171
|
-
line_width=plot_unif_kwargs.get("linewidth", 1.0),
|
|
172
|
-
)
|
|
173
|
-
else:
|
|
174
|
-
if use_hdi:
|
|
175
|
-
patch = BoxAnnotation(
|
|
176
|
-
bottom=hdi_odds[1],
|
|
177
|
-
top=hdi_odds[0],
|
|
178
|
-
fill_alpha=hdi_kwargs.pop("alpha"),
|
|
179
|
-
fill_color=hdi_kwargs.pop("color"),
|
|
180
|
-
**hdi_kwargs,
|
|
181
|
-
)
|
|
182
|
-
patch.level = "underlay"
|
|
183
|
-
ax.add_layout(patch)
|
|
184
|
-
|
|
185
|
-
# Adds horizontal reference line
|
|
186
|
-
ax.line([0, 1], [1, 1], line_color="white", line_width=1.5)
|
|
187
|
-
else:
|
|
188
|
-
for idx in range(n_unif):
|
|
189
|
-
x_s, unif_density = kde(unif[idx, :])
|
|
190
|
-
ax.line(
|
|
191
|
-
x_s,
|
|
192
|
-
unif_density,
|
|
193
|
-
line_color=plot_unif_kwargs.get("color", "black"),
|
|
194
|
-
line_alpha=plot_unif_kwargs.get("alpha", 0.1),
|
|
195
|
-
line_width=plot_unif_kwargs.get("linewidth", 1.0),
|
|
196
|
-
)
|
|
197
|
-
ax.line(
|
|
198
|
-
x_vals,
|
|
199
|
-
loo_pit_kde,
|
|
200
|
-
line_color=plot_kwargs.get("color", "black"),
|
|
201
|
-
line_alpha=plot_kwargs.get("alpha", 1.0),
|
|
202
|
-
line_width=plot_kwargs.get("linewidth", 3.0),
|
|
203
|
-
)
|
|
204
|
-
|
|
205
|
-
# Sets xlim(0, 1)
|
|
206
|
-
ax.xaxis.axis_label = xlabel
|
|
207
|
-
ax.line(0, 0)
|
|
208
|
-
ax.line(1, 0)
|
|
209
|
-
show_layout(ax, show)
|
|
210
|
-
|
|
211
|
-
return ax
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
"""Bokeh mcseplot."""
|
|
2
|
-
|
|
3
|
-
import numpy as np
|
|
4
|
-
from bokeh.models import ColumnDataSource, Span
|
|
5
|
-
from bokeh.models.glyphs import Scatter
|
|
6
|
-
from bokeh.models.annotations import Title
|
|
7
|
-
from scipy.stats import rankdata
|
|
8
|
-
|
|
9
|
-
from ....stats.stats_utils import quantile as _quantile
|
|
10
|
-
from ...plot_utils import _scale_fig_size
|
|
11
|
-
from .. import show_layout
|
|
12
|
-
from . import backend_kwarg_defaults, create_axes_grid
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def plot_mcse(
|
|
16
|
-
ax,
|
|
17
|
-
plotters,
|
|
18
|
-
length_plotters,
|
|
19
|
-
rows,
|
|
20
|
-
cols,
|
|
21
|
-
figsize,
|
|
22
|
-
errorbar,
|
|
23
|
-
rug,
|
|
24
|
-
data,
|
|
25
|
-
probs,
|
|
26
|
-
kwargs, # pylint: disable=unused-argument
|
|
27
|
-
extra_methods,
|
|
28
|
-
mean_mcse,
|
|
29
|
-
sd_mcse,
|
|
30
|
-
textsize,
|
|
31
|
-
labeller,
|
|
32
|
-
text_kwargs, # pylint: disable=unused-argument
|
|
33
|
-
rug_kwargs,
|
|
34
|
-
extra_kwargs,
|
|
35
|
-
idata,
|
|
36
|
-
rug_kind,
|
|
37
|
-
backend_kwargs,
|
|
38
|
-
show,
|
|
39
|
-
):
|
|
40
|
-
"""Bokeh mcse plot."""
|
|
41
|
-
if backend_kwargs is None:
|
|
42
|
-
backend_kwargs = {}
|
|
43
|
-
|
|
44
|
-
backend_kwargs = {
|
|
45
|
-
**backend_kwarg_defaults(),
|
|
46
|
-
**backend_kwargs,
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
(figsize, *_, _linewidth, _markersize) = _scale_fig_size(figsize, textsize, rows, cols)
|
|
50
|
-
|
|
51
|
-
extra_kwargs = {} if extra_kwargs is None else extra_kwargs
|
|
52
|
-
extra_kwargs.setdefault("linewidth", _linewidth / 2)
|
|
53
|
-
extra_kwargs.setdefault("color", "black")
|
|
54
|
-
extra_kwargs.setdefault("alpha", 0.5)
|
|
55
|
-
|
|
56
|
-
if ax is None:
|
|
57
|
-
ax = create_axes_grid(
|
|
58
|
-
length_plotters,
|
|
59
|
-
rows,
|
|
60
|
-
cols,
|
|
61
|
-
figsize=figsize,
|
|
62
|
-
backend_kwargs=backend_kwargs,
|
|
63
|
-
)
|
|
64
|
-
else:
|
|
65
|
-
ax = np.atleast_2d(ax)
|
|
66
|
-
|
|
67
|
-
for (var_name, selection, isel, x), ax_ in zip(
|
|
68
|
-
plotters, (item for item in ax.flatten() if item is not None)
|
|
69
|
-
):
|
|
70
|
-
if errorbar or rug:
|
|
71
|
-
values = data[var_name].sel(**selection).values.flatten()
|
|
72
|
-
if errorbar:
|
|
73
|
-
quantile_values = _quantile(values, probs)
|
|
74
|
-
ax_.scatter(probs, quantile_values, marker="dash")
|
|
75
|
-
ax_.multi_line(
|
|
76
|
-
list(zip(probs, probs)),
|
|
77
|
-
[(quant - err, quant + err) for quant, err in zip(quantile_values, x)],
|
|
78
|
-
)
|
|
79
|
-
else:
|
|
80
|
-
ax_.scatter(probs, x, marker="circle")
|
|
81
|
-
if extra_methods:
|
|
82
|
-
mean_mcse_i = mean_mcse[var_name].sel(**selection).values.item()
|
|
83
|
-
sd_mcse_i = sd_mcse[var_name].sel(**selection).values.item()
|
|
84
|
-
hline_mean = Span(
|
|
85
|
-
location=mean_mcse_i,
|
|
86
|
-
dimension="width",
|
|
87
|
-
line_color=extra_kwargs["color"],
|
|
88
|
-
line_width=extra_kwargs["linewidth"] * 2,
|
|
89
|
-
line_alpha=extra_kwargs["alpha"],
|
|
90
|
-
)
|
|
91
|
-
|
|
92
|
-
ax_.renderers.append(hline_mean)
|
|
93
|
-
|
|
94
|
-
hline_sd = Span(
|
|
95
|
-
location=sd_mcse_i,
|
|
96
|
-
dimension="width",
|
|
97
|
-
line_color="black",
|
|
98
|
-
line_width=extra_kwargs["linewidth"],
|
|
99
|
-
line_alpha=extra_kwargs["alpha"],
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
ax_.renderers.append(hline_sd)
|
|
103
|
-
|
|
104
|
-
if rug:
|
|
105
|
-
if rug_kwargs is None:
|
|
106
|
-
rug_kwargs = {}
|
|
107
|
-
if not hasattr(idata, "sample_stats"):
|
|
108
|
-
raise ValueError("InferenceData object must contain sample_stats for rug plot")
|
|
109
|
-
if not hasattr(idata.sample_stats, rug_kind):
|
|
110
|
-
raise ValueError(f"InferenceData does not contain {rug_kind} data")
|
|
111
|
-
rug_kwargs.setdefault("space", 0.1)
|
|
112
|
-
|
|
113
|
-
_rug_kwargs = {}
|
|
114
|
-
_rug_kwargs.setdefault("size", 8)
|
|
115
|
-
_rug_kwargs.setdefault("line_color", rug_kwargs.get("line_color", "black"))
|
|
116
|
-
_rug_kwargs.setdefault("line_width", 1)
|
|
117
|
-
_rug_kwargs.setdefault("line_alpha", 0.35)
|
|
118
|
-
_rug_kwargs.setdefault("angle", np.pi / 2)
|
|
119
|
-
|
|
120
|
-
mask = idata.sample_stats[rug_kind].values.flatten()
|
|
121
|
-
values = rankdata(values, method="average")[mask]
|
|
122
|
-
if errorbar:
|
|
123
|
-
rug_x, rug_y = (
|
|
124
|
-
values / (len(mask) - 1),
|
|
125
|
-
np.full_like(
|
|
126
|
-
values,
|
|
127
|
-
min(
|
|
128
|
-
0,
|
|
129
|
-
min(quantile_values)
|
|
130
|
-
- (max(quantile_values) - min(quantile_values)) * 0.05,
|
|
131
|
-
),
|
|
132
|
-
),
|
|
133
|
-
)
|
|
134
|
-
|
|
135
|
-
hline = Span(
|
|
136
|
-
location=min(
|
|
137
|
-
0,
|
|
138
|
-
min(quantile_values) - (max(quantile_values) - min(quantile_values)) * 0.05,
|
|
139
|
-
),
|
|
140
|
-
dimension="width",
|
|
141
|
-
line_color="black",
|
|
142
|
-
line_width=_linewidth,
|
|
143
|
-
line_alpha=0.7,
|
|
144
|
-
)
|
|
145
|
-
|
|
146
|
-
else:
|
|
147
|
-
rug_x, rug_y = (
|
|
148
|
-
values / (len(mask) - 1),
|
|
149
|
-
np.full_like(
|
|
150
|
-
values,
|
|
151
|
-
0,
|
|
152
|
-
),
|
|
153
|
-
)
|
|
154
|
-
|
|
155
|
-
hline = Span(
|
|
156
|
-
location=0,
|
|
157
|
-
dimension="width",
|
|
158
|
-
line_color="black",
|
|
159
|
-
line_width=_linewidth,
|
|
160
|
-
line_alpha=0.7,
|
|
161
|
-
)
|
|
162
|
-
|
|
163
|
-
ax_.renderers.append(hline)
|
|
164
|
-
|
|
165
|
-
glyph = Scatter(x="rug_x", y="rug_y", marker="dash", **_rug_kwargs)
|
|
166
|
-
cds_rug = ColumnDataSource({"rug_x": np.asarray(rug_x), "rug_y": np.asarray(rug_y)})
|
|
167
|
-
ax_.add_glyph(cds_rug, glyph)
|
|
168
|
-
|
|
169
|
-
title = Title()
|
|
170
|
-
title.text = labeller.make_label_vert(var_name, selection, isel)
|
|
171
|
-
ax_.title = title
|
|
172
|
-
|
|
173
|
-
ax_.xaxis.axis_label = "Quantile"
|
|
174
|
-
ax_.yaxis.axis_label = (
|
|
175
|
-
r"Value $\pm$ MCSE for quantiles" if errorbar else "MCSE for quantiles"
|
|
176
|
-
)
|
|
177
|
-
|
|
178
|
-
if not errorbar:
|
|
179
|
-
ax_.y_range._property_values["start"] = -0.05 # pylint: disable=protected-access
|
|
180
|
-
ax_.y_range._property_values["end"] = 1 # pylint: disable=protected-access
|
|
181
|
-
|
|
182
|
-
show_layout(ax, show)
|
|
183
|
-
|
|
184
|
-
return ax
|