arviz 0.23.1__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 -357
- arviz-1.0.0rc0.dist-info/METADATA +182 -0
- arviz-1.0.0rc0.dist-info/RECORD +5 -0
- {arviz-0.23.1.dist-info → arviz-1.0.0rc0.dist-info}/WHEEL +1 -2
- {arviz-0.23.1.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.1.dist-info/METADATA +0 -263
- arviz-0.23.1.dist-info/RECORD +0 -183
- arviz-0.23.1.dist-info/top_level.txt +0 -1
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
"""Bokeh Violinplot."""
|
|
2
|
-
|
|
3
|
-
import numpy as np
|
|
4
|
-
from bokeh.models.annotations import Title
|
|
5
|
-
|
|
6
|
-
from ....stats import hdi
|
|
7
|
-
from ....stats.density_utils import get_bins, histogram, kde
|
|
8
|
-
from ...plot_utils import _scale_fig_size
|
|
9
|
-
from .. import show_layout
|
|
10
|
-
from . import backend_kwarg_defaults, create_axes_grid
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def plot_violin(
|
|
14
|
-
ax,
|
|
15
|
-
plotters,
|
|
16
|
-
figsize,
|
|
17
|
-
rows,
|
|
18
|
-
cols,
|
|
19
|
-
sharex,
|
|
20
|
-
sharey,
|
|
21
|
-
shade_kwargs,
|
|
22
|
-
shade,
|
|
23
|
-
rug,
|
|
24
|
-
side,
|
|
25
|
-
rug_kwargs,
|
|
26
|
-
bw,
|
|
27
|
-
textsize,
|
|
28
|
-
labeller,
|
|
29
|
-
circular,
|
|
30
|
-
hdi_prob,
|
|
31
|
-
quartiles,
|
|
32
|
-
backend_kwargs,
|
|
33
|
-
show,
|
|
34
|
-
):
|
|
35
|
-
"""Bokeh violin plot."""
|
|
36
|
-
if backend_kwargs is None:
|
|
37
|
-
backend_kwargs = {}
|
|
38
|
-
|
|
39
|
-
backend_kwargs = {
|
|
40
|
-
**backend_kwarg_defaults(
|
|
41
|
-
("dpi", "plot.bokeh.figure.dpi"),
|
|
42
|
-
),
|
|
43
|
-
**backend_kwargs,
|
|
44
|
-
}
|
|
45
|
-
(figsize, *_, linewidth, _) = _scale_fig_size(figsize, textsize, rows, cols)
|
|
46
|
-
|
|
47
|
-
shade_kwargs = {} if shade_kwargs is None else shade_kwargs
|
|
48
|
-
rug_kwargs = {} if rug_kwargs is None else rug_kwargs
|
|
49
|
-
rug_kwargs.setdefault("fill_alpha", 0.1)
|
|
50
|
-
rug_kwargs.setdefault("line_alpha", 0.1)
|
|
51
|
-
if ax is None:
|
|
52
|
-
ax = create_axes_grid(
|
|
53
|
-
len(plotters),
|
|
54
|
-
rows,
|
|
55
|
-
cols,
|
|
56
|
-
sharex=sharex,
|
|
57
|
-
sharey=sharey,
|
|
58
|
-
figsize=figsize,
|
|
59
|
-
backend_kwargs=backend_kwargs,
|
|
60
|
-
)
|
|
61
|
-
else:
|
|
62
|
-
ax = np.atleast_2d(ax)
|
|
63
|
-
|
|
64
|
-
for (var_name, selection, isel, x), ax_ in zip(
|
|
65
|
-
plotters, (item for item in ax.flatten() if item is not None)
|
|
66
|
-
):
|
|
67
|
-
val = x.flatten()
|
|
68
|
-
if val[0].dtype.kind == "i":
|
|
69
|
-
dens = cat_hist(val, rug, side, shade, ax_, **shade_kwargs)
|
|
70
|
-
else:
|
|
71
|
-
dens = _violinplot(val, rug, side, shade, bw, circular, ax_, **shade_kwargs)
|
|
72
|
-
if rug:
|
|
73
|
-
rug_x = -np.abs(np.random.normal(scale=max(dens) / 3.5, size=len(val)))
|
|
74
|
-
ax_.scatter(rug_x, val, **rug_kwargs)
|
|
75
|
-
|
|
76
|
-
per = np.nanpercentile(val, [25, 75, 50])
|
|
77
|
-
hdi_probs = hdi(val, hdi_prob, multimodal=False, skipna=True)
|
|
78
|
-
|
|
79
|
-
if quartiles:
|
|
80
|
-
ax_.line(
|
|
81
|
-
[0, 0], per[:2], line_width=linewidth * 3, line_color="black", line_cap="round"
|
|
82
|
-
)
|
|
83
|
-
ax_.line([0, 0], hdi_probs, line_width=linewidth, line_color="black", line_cap="round")
|
|
84
|
-
ax_.scatter(
|
|
85
|
-
0,
|
|
86
|
-
per[-1],
|
|
87
|
-
marker="circle",
|
|
88
|
-
line_color="white",
|
|
89
|
-
fill_color="white",
|
|
90
|
-
size=linewidth * 1.5,
|
|
91
|
-
line_width=linewidth,
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
_title = Title()
|
|
95
|
-
_title.align = "center"
|
|
96
|
-
_title.text = labeller.make_label_vert(var_name, selection, isel)
|
|
97
|
-
ax_.title = _title
|
|
98
|
-
ax_.xaxis.major_tick_line_color = None
|
|
99
|
-
ax_.xaxis.minor_tick_line_color = None
|
|
100
|
-
ax_.xaxis.major_label_text_font_size = "0pt"
|
|
101
|
-
|
|
102
|
-
show_layout(ax, show)
|
|
103
|
-
|
|
104
|
-
return ax
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
def _violinplot(val, rug, side, shade, bw, circular, ax, **shade_kwargs):
|
|
108
|
-
"""Auxiliary function to plot violinplots."""
|
|
109
|
-
if bw == "default":
|
|
110
|
-
bw = "taylor" if circular else "experimental"
|
|
111
|
-
x, density = kde(val, circular=circular, bw=bw)
|
|
112
|
-
|
|
113
|
-
if rug and side == "both":
|
|
114
|
-
side = "right"
|
|
115
|
-
|
|
116
|
-
if side == "left":
|
|
117
|
-
dens = -density
|
|
118
|
-
elif side == "right":
|
|
119
|
-
x = x[::-1]
|
|
120
|
-
dens = density[::-1]
|
|
121
|
-
elif side == "both":
|
|
122
|
-
x = np.concatenate([x, x[::-1]])
|
|
123
|
-
dens = np.concatenate([-density, density[::-1]])
|
|
124
|
-
|
|
125
|
-
ax.harea(y=x, x1=dens, x2=np.zeros_like(dens), fill_alpha=shade, **shade_kwargs)
|
|
126
|
-
|
|
127
|
-
return density
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
def cat_hist(val, rug, side, shade, ax, **shade_kwargs):
|
|
131
|
-
"""Auxiliary function to plot discrete-violinplots."""
|
|
132
|
-
bins = get_bins(val)
|
|
133
|
-
_, binned_d, _ = histogram(val, bins=bins)
|
|
134
|
-
|
|
135
|
-
bin_edges = np.linspace(np.min(val), np.max(val), len(bins))
|
|
136
|
-
heights = np.diff(bin_edges)
|
|
137
|
-
centers = bin_edges[:-1] + heights.mean() / 2
|
|
138
|
-
bar_length = 0.5 * binned_d
|
|
139
|
-
|
|
140
|
-
if rug and side == "both":
|
|
141
|
-
side = "right"
|
|
142
|
-
|
|
143
|
-
if side == "right":
|
|
144
|
-
left = 0
|
|
145
|
-
right = bar_length
|
|
146
|
-
elif side == "left":
|
|
147
|
-
left = -bar_length
|
|
148
|
-
right = 0
|
|
149
|
-
elif side == "both":
|
|
150
|
-
left = -bar_length
|
|
151
|
-
right = bar_length
|
|
152
|
-
|
|
153
|
-
ax.hbar(
|
|
154
|
-
y=centers,
|
|
155
|
-
left=left,
|
|
156
|
-
right=right,
|
|
157
|
-
height=heights,
|
|
158
|
-
fill_alpha=shade,
|
|
159
|
-
line_alpha=shade,
|
|
160
|
-
line_color=None,
|
|
161
|
-
**shade_kwargs
|
|
162
|
-
)
|
|
163
|
-
|
|
164
|
-
return binned_d
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
# pylint: disable=wrong-import-position
|
|
2
|
-
"""Matplotlib Plotting Backend."""
|
|
3
|
-
import matplotlib as mpl
|
|
4
|
-
|
|
5
|
-
from matplotlib.cbook import normalize_kwargs
|
|
6
|
-
from matplotlib.pyplot import subplots
|
|
7
|
-
from numpy import ndenumerate
|
|
8
|
-
|
|
9
|
-
from ....rcparams import rcParams
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def backend_kwarg_defaults(*args, **kwargs):
|
|
13
|
-
"""Get default kwargs for backend.
|
|
14
|
-
|
|
15
|
-
For args add a tuple with key and rcParam key pair.
|
|
16
|
-
"""
|
|
17
|
-
defaults = {**kwargs}
|
|
18
|
-
# add needed default args from arviz.rcParams
|
|
19
|
-
for key, arg in args:
|
|
20
|
-
defaults.setdefault(key, rcParams[arg])
|
|
21
|
-
return defaults
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def backend_show(show):
|
|
25
|
-
"""Set default behaviour for show if not explicitly defined."""
|
|
26
|
-
if show is None:
|
|
27
|
-
show = rcParams["plot.matplotlib.show"]
|
|
28
|
-
return show
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
def create_axes_grid(length_plotters, rows=1, cols=1, backend_kwargs=None):
|
|
32
|
-
"""Create figure and axes for grids with multiple plots.
|
|
33
|
-
|
|
34
|
-
Parameters
|
|
35
|
-
----------
|
|
36
|
-
length_plotters : int
|
|
37
|
-
Number of axes required
|
|
38
|
-
rows : int
|
|
39
|
-
Number of rows
|
|
40
|
-
cols : int
|
|
41
|
-
Number of columns
|
|
42
|
-
backend_kwargs: dict, optional
|
|
43
|
-
kwargs for backend figure.
|
|
44
|
-
|
|
45
|
-
Returns
|
|
46
|
-
-------
|
|
47
|
-
fig : matplotlib figure
|
|
48
|
-
ax : matplotlib axes
|
|
49
|
-
"""
|
|
50
|
-
if backend_kwargs is None:
|
|
51
|
-
backend_kwargs = {}
|
|
52
|
-
|
|
53
|
-
backend_kwargs = {**backend_kwarg_defaults(), **backend_kwargs}
|
|
54
|
-
|
|
55
|
-
fig, axes = subplots(rows, cols, **backend_kwargs)
|
|
56
|
-
extra = (rows * cols) - length_plotters
|
|
57
|
-
if extra > 0:
|
|
58
|
-
for (row, col), ax in ndenumerate(axes):
|
|
59
|
-
if (row * cols + col + 1) > length_plotters:
|
|
60
|
-
ax.set_axis_off()
|
|
61
|
-
return fig, axes
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
def matplotlib_kwarg_dealiaser(args, kind):
|
|
65
|
-
"""De-aliase the kwargs passed to plots."""
|
|
66
|
-
if args is None:
|
|
67
|
-
return {}
|
|
68
|
-
matplotlib_kwarg_dealiaser_dict = {
|
|
69
|
-
"scatter": mpl.collections.PathCollection,
|
|
70
|
-
"plot": mpl.lines.Line2D,
|
|
71
|
-
"hist": mpl.patches.Patch,
|
|
72
|
-
"bar": mpl.patches.Rectangle,
|
|
73
|
-
"hexbin": mpl.collections.PolyCollection,
|
|
74
|
-
"fill_between": mpl.collections.PolyCollection,
|
|
75
|
-
"hlines": mpl.collections.LineCollection,
|
|
76
|
-
"text": mpl.text.Text,
|
|
77
|
-
"contour": mpl.contour.ContourSet,
|
|
78
|
-
"pcolormesh": mpl.collections.QuadMesh,
|
|
79
|
-
}
|
|
80
|
-
return normalize_kwargs(args, getattr(matplotlib_kwarg_dealiaser_dict[kind], "_alias_map", {}))
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
def dealiase_sel_kwargs(kwargs, prop_dict, idx):
|
|
84
|
-
"""Generate kwargs dict from kwargs and prop_dict.
|
|
85
|
-
|
|
86
|
-
Gets property at position ``idx`` for each property in prop_dict and adds it to
|
|
87
|
-
``kwargs``. Values in prop_dict are dealiased and overwrite values in
|
|
88
|
-
kwargs with the same key .
|
|
89
|
-
|
|
90
|
-
Parameters
|
|
91
|
-
----------
|
|
92
|
-
kwargs : dict
|
|
93
|
-
prop_dict : dict of {str : array_like}
|
|
94
|
-
idx : int
|
|
95
|
-
"""
|
|
96
|
-
return {
|
|
97
|
-
**kwargs,
|
|
98
|
-
**matplotlib_kwarg_dealiaser(
|
|
99
|
-
{prop: props[idx] for prop, props in prop_dict.items()}, "plot"
|
|
100
|
-
),
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
from .autocorrplot import plot_autocorr
|
|
105
|
-
from .bpvplot import plot_bpv
|
|
106
|
-
from .compareplot import plot_compare
|
|
107
|
-
from .densityplot import plot_density
|
|
108
|
-
from .distplot import plot_dist
|
|
109
|
-
from .elpdplot import plot_elpd
|
|
110
|
-
from .energyplot import plot_energy
|
|
111
|
-
from .essplot import plot_ess
|
|
112
|
-
from .forestplot import plot_forest
|
|
113
|
-
from .hdiplot import plot_hdi
|
|
114
|
-
from .kdeplot import plot_kde
|
|
115
|
-
from .khatplot import plot_khat
|
|
116
|
-
from .loopitplot import plot_loo_pit
|
|
117
|
-
from .mcseplot import plot_mcse
|
|
118
|
-
from .pairplot import plot_pair
|
|
119
|
-
from .parallelplot import plot_parallel
|
|
120
|
-
from .posteriorplot import plot_posterior
|
|
121
|
-
from .ppcplot import plot_ppc
|
|
122
|
-
from .rankplot import plot_rank
|
|
123
|
-
from .traceplot import plot_trace
|
|
124
|
-
from .violinplot import plot_violin
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"""Matplotlib Autocorrplot."""
|
|
2
|
-
|
|
3
|
-
import matplotlib.pyplot as plt
|
|
4
|
-
import numpy as np
|
|
5
|
-
|
|
6
|
-
from ....stats import autocorr
|
|
7
|
-
from ...plot_utils import _scale_fig_size
|
|
8
|
-
from . import backend_kwarg_defaults, backend_show, create_axes_grid
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def plot_autocorr(
|
|
12
|
-
axes,
|
|
13
|
-
plotters,
|
|
14
|
-
max_lag,
|
|
15
|
-
figsize,
|
|
16
|
-
rows,
|
|
17
|
-
cols,
|
|
18
|
-
combined,
|
|
19
|
-
textsize,
|
|
20
|
-
labeller,
|
|
21
|
-
backend_kwargs,
|
|
22
|
-
show,
|
|
23
|
-
):
|
|
24
|
-
"""Matplotlib autocorrplot."""
|
|
25
|
-
if backend_kwargs is None:
|
|
26
|
-
backend_kwargs = {}
|
|
27
|
-
|
|
28
|
-
backend_kwargs = {
|
|
29
|
-
**backend_kwarg_defaults(),
|
|
30
|
-
**backend_kwargs,
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
figsize, _, titlesize, xt_labelsize, linewidth, _ = _scale_fig_size(
|
|
34
|
-
figsize, textsize, rows, cols
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
backend_kwargs.setdefault("figsize", figsize)
|
|
38
|
-
backend_kwargs.setdefault("sharex", True)
|
|
39
|
-
backend_kwargs.setdefault("sharey", True)
|
|
40
|
-
backend_kwargs.setdefault("squeeze", True)
|
|
41
|
-
|
|
42
|
-
if axes is None:
|
|
43
|
-
_, axes = create_axes_grid(
|
|
44
|
-
len(plotters),
|
|
45
|
-
rows,
|
|
46
|
-
cols,
|
|
47
|
-
backend_kwargs=backend_kwargs,
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
for (var_name, selection, isel, x), ax in zip(plotters, np.ravel(axes)):
|
|
51
|
-
x_prime = x
|
|
52
|
-
if combined:
|
|
53
|
-
x_prime = x.flatten()
|
|
54
|
-
c_i = 1.96 / x_prime.size**0.5
|
|
55
|
-
y = autocorr(x_prime)
|
|
56
|
-
|
|
57
|
-
ax.fill_between([0, max_lag], -c_i, c_i, color="0.75")
|
|
58
|
-
ax.vlines(x=np.arange(0, max_lag), ymin=0, ymax=y[0:max_lag], lw=linewidth)
|
|
59
|
-
|
|
60
|
-
ax.set_title(
|
|
61
|
-
labeller.make_label_vert(var_name, selection, isel), fontsize=titlesize, wrap=True
|
|
62
|
-
)
|
|
63
|
-
ax.tick_params(labelsize=xt_labelsize)
|
|
64
|
-
|
|
65
|
-
if np.asarray(axes).size > 0:
|
|
66
|
-
np.asarray(axes).item(0).set_xlim(0, max_lag)
|
|
67
|
-
np.asarray(axes).item(0).set_ylim(-1, 1)
|
|
68
|
-
|
|
69
|
-
if backend_show(show):
|
|
70
|
-
plt.show()
|
|
71
|
-
|
|
72
|
-
return axes
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import matplotlib.pyplot as plt
|
|
2
|
-
|
|
3
|
-
from . import backend_kwarg_defaults, backend_show, create_axes_grid, matplotlib_kwarg_dealiaser
|
|
4
|
-
from ...distplot import plot_dist
|
|
5
|
-
from ...plot_utils import _scale_fig_size
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def plot_bf(
|
|
9
|
-
ax,
|
|
10
|
-
bf_10,
|
|
11
|
-
bf_01,
|
|
12
|
-
prior,
|
|
13
|
-
posterior,
|
|
14
|
-
ref_val,
|
|
15
|
-
prior_at_ref_val,
|
|
16
|
-
posterior_at_ref_val,
|
|
17
|
-
var_name,
|
|
18
|
-
colors,
|
|
19
|
-
figsize,
|
|
20
|
-
textsize,
|
|
21
|
-
plot_kwargs,
|
|
22
|
-
hist_kwargs,
|
|
23
|
-
backend_kwargs,
|
|
24
|
-
show,
|
|
25
|
-
):
|
|
26
|
-
"""Matplotlib Bayes Factor plot."""
|
|
27
|
-
if backend_kwargs is None:
|
|
28
|
-
backend_kwargs = {}
|
|
29
|
-
|
|
30
|
-
if hist_kwargs is None:
|
|
31
|
-
hist_kwargs = {}
|
|
32
|
-
|
|
33
|
-
backend_kwargs = {
|
|
34
|
-
**backend_kwarg_defaults(),
|
|
35
|
-
**backend_kwargs,
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
figsize, _, _, _, linewidth, _ = _scale_fig_size(figsize, textsize, 1, 1)
|
|
39
|
-
|
|
40
|
-
plot_kwargs = matplotlib_kwarg_dealiaser(plot_kwargs, "plot")
|
|
41
|
-
plot_kwargs.setdefault("linewidth", linewidth)
|
|
42
|
-
hist_kwargs.setdefault("alpha", 0.5)
|
|
43
|
-
|
|
44
|
-
backend_kwargs.setdefault("figsize", figsize)
|
|
45
|
-
backend_kwargs.setdefault("squeeze", True)
|
|
46
|
-
|
|
47
|
-
if ax is None:
|
|
48
|
-
_, ax = create_axes_grid(1, backend_kwargs=backend_kwargs)
|
|
49
|
-
|
|
50
|
-
plot_dist(
|
|
51
|
-
prior,
|
|
52
|
-
color=colors[0],
|
|
53
|
-
label="Prior",
|
|
54
|
-
ax=ax,
|
|
55
|
-
plot_kwargs=plot_kwargs,
|
|
56
|
-
hist_kwargs=hist_kwargs,
|
|
57
|
-
)
|
|
58
|
-
plot_dist(
|
|
59
|
-
posterior,
|
|
60
|
-
color=colors[1],
|
|
61
|
-
label="Posterior",
|
|
62
|
-
ax=ax,
|
|
63
|
-
plot_kwargs=plot_kwargs,
|
|
64
|
-
hist_kwargs=hist_kwargs,
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
ax.plot(ref_val, posterior_at_ref_val, "ko", lw=1.5)
|
|
68
|
-
ax.plot(ref_val, prior_at_ref_val, "ko", lw=1.5)
|
|
69
|
-
ax.axvline(ref_val, color="k", ls="--")
|
|
70
|
-
ax.set_xlabel(var_name)
|
|
71
|
-
ax.set_ylabel("Density")
|
|
72
|
-
ax.set_title(f"The BF_10 is {bf_10:.2f}\nThe BF_01 is {bf_01:.2f}")
|
|
73
|
-
plt.legend()
|
|
74
|
-
|
|
75
|
-
if backend_show(show):
|
|
76
|
-
plt.show()
|
|
77
|
-
|
|
78
|
-
return ax
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
"""Matplotib Bayesian p-value Posterior predictive plot."""
|
|
2
|
-
|
|
3
|
-
import matplotlib.pyplot as plt
|
|
4
|
-
import numpy as np
|
|
5
|
-
from scipy import stats
|
|
6
|
-
|
|
7
|
-
from ....stats.density_utils import kde
|
|
8
|
-
from ....stats.stats_utils import smooth_data
|
|
9
|
-
from ...kdeplot import plot_kde
|
|
10
|
-
from ...plot_utils import (
|
|
11
|
-
_scale_fig_size,
|
|
12
|
-
is_valid_quantile,
|
|
13
|
-
sample_reference_distribution,
|
|
14
|
-
)
|
|
15
|
-
from . import backend_kwarg_defaults, backend_show, create_axes_grid, matplotlib_kwarg_dealiaser
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def plot_bpv(
|
|
19
|
-
ax,
|
|
20
|
-
length_plotters,
|
|
21
|
-
rows,
|
|
22
|
-
cols,
|
|
23
|
-
obs_plotters,
|
|
24
|
-
pp_plotters,
|
|
25
|
-
total_pp_samples,
|
|
26
|
-
kind,
|
|
27
|
-
t_stat,
|
|
28
|
-
bpv,
|
|
29
|
-
plot_mean,
|
|
30
|
-
reference,
|
|
31
|
-
mse,
|
|
32
|
-
n_ref,
|
|
33
|
-
hdi_prob,
|
|
34
|
-
color,
|
|
35
|
-
figsize,
|
|
36
|
-
textsize,
|
|
37
|
-
labeller,
|
|
38
|
-
plot_ref_kwargs,
|
|
39
|
-
backend_kwargs,
|
|
40
|
-
show,
|
|
41
|
-
smoothing,
|
|
42
|
-
):
|
|
43
|
-
"""Matplotlib bpv plot."""
|
|
44
|
-
if backend_kwargs is None:
|
|
45
|
-
backend_kwargs = {}
|
|
46
|
-
|
|
47
|
-
backend_kwargs = {
|
|
48
|
-
**backend_kwarg_defaults(),
|
|
49
|
-
**backend_kwargs,
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
figsize, ax_labelsize, _, _, linewidth, markersize = _scale_fig_size(
|
|
53
|
-
figsize, textsize, rows, cols
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
backend_kwargs.setdefault("figsize", figsize)
|
|
57
|
-
backend_kwargs.setdefault("squeeze", True)
|
|
58
|
-
|
|
59
|
-
if (kind == "u_value") and (reference == "analytical"):
|
|
60
|
-
plot_ref_kwargs = matplotlib_kwarg_dealiaser(plot_ref_kwargs, "fill_between")
|
|
61
|
-
else:
|
|
62
|
-
plot_ref_kwargs = matplotlib_kwarg_dealiaser(plot_ref_kwargs, "plot")
|
|
63
|
-
|
|
64
|
-
if kind == "p_value" and reference == "analytical":
|
|
65
|
-
plot_ref_kwargs.setdefault("color", "k")
|
|
66
|
-
plot_ref_kwargs.setdefault("linestyle", "--")
|
|
67
|
-
elif kind == "u_value" and reference == "analytical":
|
|
68
|
-
plot_ref_kwargs.setdefault("color", "k")
|
|
69
|
-
plot_ref_kwargs.setdefault("alpha", 0.2)
|
|
70
|
-
else:
|
|
71
|
-
plot_ref_kwargs.setdefault("alpha", 0.1)
|
|
72
|
-
plot_ref_kwargs.setdefault("color", color)
|
|
73
|
-
|
|
74
|
-
if ax is None:
|
|
75
|
-
_, axes = create_axes_grid(length_plotters, rows, cols, backend_kwargs=backend_kwargs)
|
|
76
|
-
else:
|
|
77
|
-
axes = np.asarray(ax)
|
|
78
|
-
if axes.size < length_plotters:
|
|
79
|
-
raise ValueError(
|
|
80
|
-
f"Found {length_plotters} variables to plot but {axes.size} axes instances. "
|
|
81
|
-
"Axes instances must at minimum be equal to variables."
|
|
82
|
-
)
|
|
83
|
-
|
|
84
|
-
for i, ax_i in enumerate(np.ravel(axes)[:length_plotters]):
|
|
85
|
-
var_name, selection, isel, obs_vals = obs_plotters[i]
|
|
86
|
-
pp_var_name, _, _, pp_vals = pp_plotters[i]
|
|
87
|
-
|
|
88
|
-
obs_vals = obs_vals.flatten()
|
|
89
|
-
pp_vals = pp_vals.reshape(total_pp_samples, -1)
|
|
90
|
-
|
|
91
|
-
if (obs_vals.dtype.kind == "i" or pp_vals.dtype.kind == "i") and smoothing is True:
|
|
92
|
-
obs_vals, pp_vals = smooth_data(obs_vals, pp_vals)
|
|
93
|
-
|
|
94
|
-
if kind == "p_value":
|
|
95
|
-
tstat_pit = np.mean(pp_vals <= obs_vals, axis=-1)
|
|
96
|
-
x_s, tstat_pit_dens = kde(tstat_pit)
|
|
97
|
-
ax_i.plot(x_s, tstat_pit_dens, linewidth=linewidth, color=color)
|
|
98
|
-
ax_i.set_yticks([])
|
|
99
|
-
if reference is not None:
|
|
100
|
-
dist = stats.beta(obs_vals.size / 2, obs_vals.size / 2)
|
|
101
|
-
if reference == "analytical":
|
|
102
|
-
lwb = dist.ppf((1 - 0.9999) / 2)
|
|
103
|
-
upb = 1 - lwb
|
|
104
|
-
x = np.linspace(lwb, upb, 500)
|
|
105
|
-
dens_ref = dist.pdf(x)
|
|
106
|
-
ax_i.plot(x, dens_ref, zorder=1, **plot_ref_kwargs)
|
|
107
|
-
elif reference == "samples":
|
|
108
|
-
x_ss, u_dens = sample_reference_distribution(
|
|
109
|
-
dist,
|
|
110
|
-
(
|
|
111
|
-
tstat_pit_dens.size,
|
|
112
|
-
n_ref,
|
|
113
|
-
),
|
|
114
|
-
)
|
|
115
|
-
ax_i.plot(x_ss, u_dens, linewidth=linewidth, **plot_ref_kwargs)
|
|
116
|
-
|
|
117
|
-
elif kind == "u_value":
|
|
118
|
-
tstat_pit = np.mean(pp_vals <= obs_vals, axis=0)
|
|
119
|
-
x_s, tstat_pit_dens = kde(tstat_pit)
|
|
120
|
-
ax_i.plot(x_s, tstat_pit_dens, color=color)
|
|
121
|
-
if reference is not None:
|
|
122
|
-
if reference == "analytical":
|
|
123
|
-
n_obs = obs_vals.size
|
|
124
|
-
hdi_ = stats.beta(n_obs / 2, n_obs / 2).ppf((1 - hdi_prob) / 2)
|
|
125
|
-
hdi_odds = (hdi_ / (1 - hdi_), (1 - hdi_) / hdi_)
|
|
126
|
-
ax_i.axhspan(*hdi_odds, **plot_ref_kwargs)
|
|
127
|
-
ax_i.axhline(1, color="w", zorder=1)
|
|
128
|
-
elif reference == "samples":
|
|
129
|
-
dist = stats.uniform(0, 1)
|
|
130
|
-
x_ss, u_dens = sample_reference_distribution(dist, (tstat_pit_dens.size, n_ref))
|
|
131
|
-
ax_i.plot(x_ss, u_dens, linewidth=linewidth, **plot_ref_kwargs)
|
|
132
|
-
if mse:
|
|
133
|
-
ax_i.plot(0, 0, label=f"mse={np.mean((1 - tstat_pit_dens)**2) * 100:.2f}")
|
|
134
|
-
ax_i.legend()
|
|
135
|
-
|
|
136
|
-
ax_i.set_ylim(0, None)
|
|
137
|
-
ax_i.set_xlim(0, 1)
|
|
138
|
-
else:
|
|
139
|
-
if t_stat in ["mean", "median", "std"]:
|
|
140
|
-
if t_stat == "mean":
|
|
141
|
-
tfunc = np.mean
|
|
142
|
-
elif t_stat == "median":
|
|
143
|
-
tfunc = np.median
|
|
144
|
-
elif t_stat == "std":
|
|
145
|
-
tfunc = np.std
|
|
146
|
-
obs_vals = tfunc(obs_vals)
|
|
147
|
-
pp_vals = tfunc(pp_vals, axis=1)
|
|
148
|
-
elif hasattr(t_stat, "__call__"):
|
|
149
|
-
obs_vals = t_stat(obs_vals.flatten())
|
|
150
|
-
pp_vals = t_stat(pp_vals)
|
|
151
|
-
elif is_valid_quantile(t_stat):
|
|
152
|
-
t_stat = float(t_stat)
|
|
153
|
-
obs_vals = np.quantile(obs_vals, q=t_stat)
|
|
154
|
-
pp_vals = np.quantile(pp_vals, q=t_stat, axis=1)
|
|
155
|
-
else:
|
|
156
|
-
raise ValueError(f"T statistics {t_stat} not implemented")
|
|
157
|
-
|
|
158
|
-
plot_kde(pp_vals, ax=ax_i, plot_kwargs={"color": color})
|
|
159
|
-
ax_i.set_yticks([])
|
|
160
|
-
if bpv:
|
|
161
|
-
p_value = np.mean(pp_vals <= obs_vals)
|
|
162
|
-
ax_i.plot(obs_vals, 0, label=f"bpv={p_value:.2f}", alpha=0)
|
|
163
|
-
ax_i.legend()
|
|
164
|
-
|
|
165
|
-
if plot_mean:
|
|
166
|
-
ax_i.plot(
|
|
167
|
-
obs_vals.mean(), 0, "o", color=color, markeredgecolor="k", markersize=markersize
|
|
168
|
-
)
|
|
169
|
-
|
|
170
|
-
ax_i.set_title(
|
|
171
|
-
labeller.make_pp_label(var_name, pp_var_name, selection, isel), fontsize=ax_labelsize
|
|
172
|
-
)
|
|
173
|
-
|
|
174
|
-
if backend_show(show):
|
|
175
|
-
plt.show()
|
|
176
|
-
|
|
177
|
-
return axes
|