Plot timeseries data.
InferenceData
arviz.InferenceData
object.
str
Variable name from observed_data
. Values to be plotted on y-axis before holdout.
str
, Optional
Values to be plotted on x-axis before holdout. If None, coords of y
dims is chosen.
str
, optional
Variable name from posterior_predictive
. Assumed to be of shape (chain, draw, *y_dims)
.
str
, optional
Variable name from observed_data
. It represents the observed data after the holdout period. Useful while testing the model, when you want to compare observed test data with predictions/forecasts.
str
, optional
Variable name from posterior_predictive
. It represents forecasts (posterior predictive) values after holdout period. Useful to compare observed vs predictions/forecasts. Assumed shape (chain, draw, *shape)
.
str
, Defaults
to
coords
of y.
Variable name from constant_data
. If None, coords of y_holdout
or coords of y_forecast
(either of the two available) is chosen.
Should be present in y.dims
. Necessary for selection of x
if x
is None and y
is multidimensional.
Should be present in y_holdout.dims
or y_forecats.dims
. Necessary to choose x_holdout
if x
is None and if y_holdout
or y_forecasts
is multidimensional.
int
, default 100
Number of posterior predictive samples drawn from y_hat
and y_forecasts
.
Select plotting backend.
dict
, optional
Passed to matplotlib.axes.Axes.plot()
in matplotlib.
dict
, optional
Passed to matplotlib.axes.Axes.plot()
in matplotlib.
dict
, optional
Passed to matplotlib.axes.Axes.plot()
in matplotlib.
dict
, optional
Passed to matplotlib.axes.Axes.axvline()
in matplotlib.
dict
, optional
These are kwargs specific to the backend being used. Passed to matplotlib.pyplot.subplots()
.
tuple
, optional
Figure size. If None, it will be defined automatically.
float
, optional
Text size scaling factor for labels, titles and lines. If None, it will be autoscaled based on figsize
.
matplotlib
axes
or bokeh
figures.
See also
plot_lm
Posterior predictive and mean plots for regression-like data.
plot_ppc
Plot for posterior/prior predictive checks.
Examples
Plot timeseries default plot
>>> import arviz as az >>> nchains, ndraws = (4, 500) >>> obs_data = { ... "y": 2 * np.arange(1, 9) + 3, ... "z": 2 * np.arange(8, 12) + 3, ... } >>> posterior_predictive = { ... "y": np.random.normal( ... (obs_data["y"] * 1.2) - 3, size=(nchains, ndraws, len(obs_data["y"])) ... ), ... "z": np.random.normal( ... (obs_data["z"] * 1.2) - 3, size=(nchains, ndraws, len(obs_data["z"])) ... ), ... } >>> idata = az.from_dict( ... observed_data=obs_data, ... posterior_predictive=posterior_predictive, ... coords={"obs_dim": np.arange(1, 9), "pred_dim": np.arange(8, 12)}, ... dims={"y": ["obs_dim"], "z": ["pred_dim"]}, ... ) >>> ax = az.plot_ts(idata=idata, y="y", y_holdout="z")
Plot timeseries multidim plot
>>> ndim1, ndim2 = (5, 7) >>> data = { ... "y": np.random.normal(size=(ndim1, ndim2)), ... "z": np.random.normal(size=(ndim1, ndim2)), ... } >>> posterior_predictive = { ... "y": np.random.randn(nchains, ndraws, ndim1, ndim2), ... "z": np.random.randn(nchains, ndraws, ndim1, ndim2), ... } >>> const_data = {"x": np.arange(1, 6), "x_pred": np.arange(5, 10)} >>> idata = az.from_dict( ... observed_data=data, ... posterior_predictive=posterior_predictive, ... constant_data=const_data, ... dims={ ... "y": ["dim1", "dim2"], ... "z": ["holdout_dim1", "holdout_dim2"], ... }, ... coords={ ... "dim1": range(ndim1), ... "dim2": range(ndim2), ... "holdout_dim1": range(ndim1 - 1, ndim1 + 4), ... "holdout_dim2": range(ndim2 - 1, ndim2 + 6), ... }, ... ) >>> az.plot_ts( ... idata=idata, ... y="y", ... plot_dim="dim1", ... y_holdout="z", ... holdout_dim="holdout_dim1", ... )
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4