partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
TfpConverter.posterior_to_xarray
Convert the posterior to an xarray dataset.
arviz/data/io_tfp.py
def posterior_to_xarray(self): """Convert the posterior to an xarray dataset.""" data = {} for i, var_name in enumerate(self.var_names): data[var_name] = np.expand_dims(self.posterior[i], axis=0) return dict_to_dataset(data, library=self.tfp, coords=self.coords, dims=sel...
def posterior_to_xarray(self): """Convert the posterior to an xarray dataset.""" data = {} for i, var_name in enumerate(self.var_names): data[var_name] = np.expand_dims(self.posterior[i], axis=0) return dict_to_dataset(data, library=self.tfp, coords=self.coords, dims=sel...
[ "Convert", "the", "posterior", "to", "an", "xarray", "dataset", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_tfp.py#L52-L57
[ "def", "posterior_to_xarray", "(", "self", ")", ":", "data", "=", "{", "}", "for", "i", ",", "var_name", "in", "enumerate", "(", "self", ".", "var_names", ")", ":", "data", "[", "var_name", "]", "=", "np", ".", "expand_dims", "(", "self", ".", "poste...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
TfpConverter.observed_data_to_xarray
Convert observed data to xarray.
arviz/data/io_tfp.py
def observed_data_to_xarray(self): """Convert observed data to xarray.""" if self.observed is None: return None observed_data = {} if isinstance(self.observed, self.tf.Tensor): with self.tf.Session() as sess: vals = sess.run(self.observed,...
def observed_data_to_xarray(self): """Convert observed data to xarray.""" if self.observed is None: return None observed_data = {} if isinstance(self.observed, self.tf.Tensor): with self.tf.Session() as sess: vals = sess.run(self.observed,...
[ "Convert", "observed", "data", "to", "xarray", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_tfp.py#L59-L83
[ "def", "observed_data_to_xarray", "(", "self", ")", ":", "if", "self", ".", "observed", "is", "None", ":", "return", "None", "observed_data", "=", "{", "}", "if", "isinstance", "(", "self", ".", "observed", ",", "self", ".", "tf", ".", "Tensor", ")", "...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
TfpConverter.posterior_predictive_to_xarray
Convert posterior_predictive samples to xarray.
arviz/data/io_tfp.py
def posterior_predictive_to_xarray(self): """Convert posterior_predictive samples to xarray.""" if self.model_fn is None: return None posterior_preds = [] sample_size = self.posterior[0].shape[0] for i in np.arange(0, sample_size, int(sample_size / self.post...
def posterior_predictive_to_xarray(self): """Convert posterior_predictive samples to xarray.""" if self.model_fn is None: return None posterior_preds = [] sample_size = self.posterior[0].shape[0] for i in np.arange(0, sample_size, int(sample_size / self.post...
[ "Convert", "posterior_predictive", "samples", "to", "xarray", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_tfp.py#L95-L121
[ "def", "posterior_predictive_to_xarray", "(", "self", ")", ":", "if", "self", ".", "model_fn", "is", "None", ":", "return", "None", "posterior_preds", "=", "[", "]", "sample_size", "=", "self", ".", "posterior", "[", "0", "]", ".", "shape", "[", "0", "]"...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
TfpConverter.sample_stats_to_xarray
Extract sample_stats from tfp trace.
arviz/data/io_tfp.py
def sample_stats_to_xarray(self): """Extract sample_stats from tfp trace.""" if self.model_fn is None or self.observed is None: return None log_likelihood = [] sample_size = self.posterior[0].shape[0] for i in range(sample_size): variables = {} ...
def sample_stats_to_xarray(self): """Extract sample_stats from tfp trace.""" if self.model_fn is None or self.observed is None: return None log_likelihood = [] sample_size = self.posterior[0].shape[0] for i in range(sample_size): variables = {} ...
[ "Extract", "sample_stats", "from", "tfp", "trace", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_tfp.py#L123-L150
[ "def", "sample_stats_to_xarray", "(", "self", ")", ":", "if", "self", ".", "model_fn", "is", "None", "or", "self", ".", "observed", "is", "None", ":", "return", "None", "log_likelihood", "=", "[", "]", "sample_size", "=", "self", ".", "posterior", "[", "...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
TfpConverter.to_inference_data
Convert all available data to an InferenceData object. Note that if groups can not be created (i.e., there is no `trace`, so the `posterior` and `sample_stats` can not be extracted), then the InferenceData will not have those groups.
arviz/data/io_tfp.py
def to_inference_data(self): """Convert all available data to an InferenceData object. Note that if groups can not be created (i.e., there is no `trace`, so the `posterior` and `sample_stats` can not be extracted), then the InferenceData will not have those groups. """ ...
def to_inference_data(self): """Convert all available data to an InferenceData object. Note that if groups can not be created (i.e., there is no `trace`, so the `posterior` and `sample_stats` can not be extracted), then the InferenceData will not have those groups. """ ...
[ "Convert", "all", "available", "data", "to", "an", "InferenceData", "object", ".", "Note", "that", "if", "groups", "can", "not", "be", "created", "(", "i", ".", "e", ".", "there", "is", "no", "trace", "so", "the", "posterior", "and", "sample_stats", "can...
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_tfp.py#L152-L166
[ "def", "to_inference_data", "(", "self", ")", ":", "return", "InferenceData", "(", "*", "*", "{", "\"posterior\"", ":", "self", ".", "posterior_to_xarray", "(", ")", ",", "\"sample_stats\"", ":", "self", ".", "sample_stats_to_xarray", "(", ")", ",", "\"posteri...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
from_pymc3
Convert pymc3 data into an InferenceData object.
arviz/data/io_pymc3.py
def from_pymc3(trace=None, *, prior=None, posterior_predictive=None, coords=None, dims=None): """Convert pymc3 data into an InferenceData object.""" return PyMC3Converter( trace=trace, prior=prior, posterior_predictive=posterior_predictive, coords=coords, dims=dims, )...
def from_pymc3(trace=None, *, prior=None, posterior_predictive=None, coords=None, dims=None): """Convert pymc3 data into an InferenceData object.""" return PyMC3Converter( trace=trace, prior=prior, posterior_predictive=posterior_predictive, coords=coords, dims=dims, )...
[ "Convert", "pymc3", "data", "into", "an", "InferenceData", "object", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_pymc3.py#L145-L153
[ "def", "from_pymc3", "(", "trace", "=", "None", ",", "*", ",", "prior", "=", "None", ",", "posterior_predictive", "=", "None", ",", "coords", "=", "None", ",", "dims", "=", "None", ")", ":", "return", "PyMC3Converter", "(", "trace", "=", "trace", ",", ...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
PyMC3Converter._extract_log_likelihood
Compute log likelihood of each observation. Return None if there is not exactly 1 observed random variable.
arviz/data/io_pymc3.py
def _extract_log_likelihood(self): """Compute log likelihood of each observation. Return None if there is not exactly 1 observed random variable. """ # This next line is brittle and may not work forever, but is a secret # way to access the model from the trace. model = s...
def _extract_log_likelihood(self): """Compute log likelihood of each observation. Return None if there is not exactly 1 observed random variable. """ # This next line is brittle and may not work forever, but is a secret # way to access the model from the trace. model = s...
[ "Compute", "log", "likelihood", "of", "each", "observation", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_pymc3.py#L25-L57
[ "def", "_extract_log_likelihood", "(", "self", ")", ":", "# This next line is brittle and may not work forever, but is a secret", "# way to access the model from the trace.", "model", "=", "self", ".", "trace", ".", "_straces", "[", "0", "]", ".", "model", "# pylint: disable=...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
PyMC3Converter.posterior_to_xarray
Convert the posterior to an xarray dataset.
arviz/data/io_pymc3.py
def posterior_to_xarray(self): """Convert the posterior to an xarray dataset.""" var_names = self.pymc3.util.get_default_varnames( # pylint: disable=no-member self.trace.varnames, include_transformed=False ) data = {} for var_name in var_names: data[var_n...
def posterior_to_xarray(self): """Convert the posterior to an xarray dataset.""" var_names = self.pymc3.util.get_default_varnames( # pylint: disable=no-member self.trace.varnames, include_transformed=False ) data = {} for var_name in var_names: data[var_n...
[ "Convert", "the", "posterior", "to", "an", "xarray", "dataset", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_pymc3.py#L60-L68
[ "def", "posterior_to_xarray", "(", "self", ")", ":", "var_names", "=", "self", ".", "pymc3", ".", "util", ".", "get_default_varnames", "(", "# pylint: disable=no-member", "self", ".", "trace", ".", "varnames", ",", "include_transformed", "=", "False", ")", "data...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
PyMC3Converter.sample_stats_to_xarray
Extract sample_stats from PyMC3 trace.
arviz/data/io_pymc3.py
def sample_stats_to_xarray(self): """Extract sample_stats from PyMC3 trace.""" rename_key = {"model_logp": "lp"} data = {} for stat in self.trace.stat_names: name = rename_key.get(stat, stat) data[name] = np.array(self.trace.get_sampler_stats(stat, combine=False))...
def sample_stats_to_xarray(self): """Extract sample_stats from PyMC3 trace.""" rename_key = {"model_logp": "lp"} data = {} for stat in self.trace.stat_names: name = rename_key.get(stat, stat) data[name] = np.array(self.trace.get_sampler_stats(stat, combine=False))...
[ "Extract", "sample_stats", "from", "PyMC3", "trace", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_pymc3.py#L71-L85
[ "def", "sample_stats_to_xarray", "(", "self", ")", ":", "rename_key", "=", "{", "\"model_logp\"", ":", "\"lp\"", "}", "data", "=", "{", "}", "for", "stat", "in", "self", ".", "trace", ".", "stat_names", ":", "name", "=", "rename_key", ".", "get", "(", ...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
PyMC3Converter.posterior_predictive_to_xarray
Convert posterior_predictive samples to xarray.
arviz/data/io_pymc3.py
def posterior_predictive_to_xarray(self): """Convert posterior_predictive samples to xarray.""" data = {k: np.expand_dims(v, 0) for k, v in self.posterior_predictive.items()} return dict_to_dataset(data, library=self.pymc3, coords=self.coords, dims=self.dims)
def posterior_predictive_to_xarray(self): """Convert posterior_predictive samples to xarray.""" data = {k: np.expand_dims(v, 0) for k, v in self.posterior_predictive.items()} return dict_to_dataset(data, library=self.pymc3, coords=self.coords, dims=self.dims)
[ "Convert", "posterior_predictive", "samples", "to", "xarray", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_pymc3.py#L88-L91
[ "def", "posterior_predictive_to_xarray", "(", "self", ")", ":", "data", "=", "{", "k", ":", "np", ".", "expand_dims", "(", "v", ",", "0", ")", "for", "k", ",", "v", "in", "self", ".", "posterior_predictive", ".", "items", "(", ")", "}", "return", "di...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
PyMC3Converter.prior_to_xarray
Convert prior samples to xarray.
arviz/data/io_pymc3.py
def prior_to_xarray(self): """Convert prior samples to xarray.""" return dict_to_dataset( {k: np.expand_dims(v, 0) for k, v in self.prior.items()}, library=self.pymc3, coords=self.coords, dims=self.dims, )
def prior_to_xarray(self): """Convert prior samples to xarray.""" return dict_to_dataset( {k: np.expand_dims(v, 0) for k, v in self.prior.items()}, library=self.pymc3, coords=self.coords, dims=self.dims, )
[ "Convert", "prior", "samples", "to", "xarray", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_pymc3.py#L94-L101
[ "def", "prior_to_xarray", "(", "self", ")", ":", "return", "dict_to_dataset", "(", "{", "k", ":", "np", ".", "expand_dims", "(", "v", ",", "0", ")", "for", "k", ",", "v", "in", "self", ".", "prior", ".", "items", "(", ")", "}", ",", "library", "=...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
PyMC3Converter.observed_data_to_xarray
Convert observed data to xarray.
arviz/data/io_pymc3.py
def observed_data_to_xarray(self): """Convert observed data to xarray.""" # This next line is brittle and may not work forever, but is a secret # way to access the model from the trace. model = self.trace._straces[0].model # pylint: disable=protected-access observations = {obs....
def observed_data_to_xarray(self): """Convert observed data to xarray.""" # This next line is brittle and may not work forever, but is a secret # way to access the model from the trace. model = self.trace._straces[0].model # pylint: disable=protected-access observations = {obs....
[ "Convert", "observed", "data", "to", "xarray", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_pymc3.py#L104-L125
[ "def", "observed_data_to_xarray", "(", "self", ")", ":", "# This next line is brittle and may not work forever, but is a secret", "# way to access the model from the trace.", "model", "=", "self", ".", "trace", ".", "_straces", "[", "0", "]", ".", "model", "# pylint: disable=...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
plot_posterior
Plot Posterior densities in the style of John K. Kruschke's book. Parameters ---------- data : obj Any object that can be converted to an az.InferenceData object Refer to documentation of az.convert_to_dataset for details var_names : list of variable names Variables to be plotte...
arviz/plots/posteriorplot.py
def plot_posterior( data, var_names=None, coords=None, figsize=None, textsize=None, credible_interval=0.94, round_to=1, point_estimate="mean", rope=None, ref_val=None, kind="kde", bw=4.5, bins=None, ax=None, **kwargs ): """Plot Posterior densities in the s...
def plot_posterior( data, var_names=None, coords=None, figsize=None, textsize=None, credible_interval=0.94, round_to=1, point_estimate="mean", rope=None, ref_val=None, kind="kde", bw=4.5, bins=None, ax=None, **kwargs ): """Plot Posterior densities in the s...
[ "Plot", "Posterior", "densities", "in", "the", "style", "of", "John", "K", ".", "Kruschke", "s", "book", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/plots/posteriorplot.py#L20-L188
[ "def", "plot_posterior", "(", "data", ",", "var_names", "=", "None", ",", "coords", "=", "None", ",", "figsize", "=", "None", ",", "textsize", "=", "None", ",", "credible_interval", "=", "0.94", ",", "round_to", "=", "1", ",", "point_estimate", "=", "\"m...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
_plot_posterior_op
Artist to draw posterior.
arviz/plots/posteriorplot.py
def _plot_posterior_op( values, var_name, selection, ax, bw, linewidth, bins, kind, point_estimate, round_to, credible_interval, ref_val, rope, ax_labelsize, xt_labelsize, **kwargs ): # noqa: D202 """Artist to draw posterior.""" def format_as_per...
def _plot_posterior_op( values, var_name, selection, ax, bw, linewidth, bins, kind, point_estimate, round_to, credible_interval, ref_val, rope, ax_labelsize, xt_labelsize, **kwargs ): # noqa: D202 """Artist to draw posterior.""" def format_as_per...
[ "Artist", "to", "draw", "posterior", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/plots/posteriorplot.py#L191-L382
[ "def", "_plot_posterior_op", "(", "values", ",", "var_name", ",", "selection", ",", "ax", ",", "bw", ",", "linewidth", ",", "bins", ",", "kind", ",", "point_estimate", ",", "round_to", ",", "credible_interval", ",", "ref_val", ",", "rope", ",", "ax_labelsize...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
bfmi
r"""Calculate the estimated Bayesian fraction of missing information (BFMI). BFMI quantifies how well momentum resampling matches the marginal energy distribution. For more information on BFMI, see https://arxiv.org/pdf/1604.00695v1.pdf. The current advice is that values smaller than 0.3 indicate poor samp...
arviz/stats/stats.py
def bfmi(energy): r"""Calculate the estimated Bayesian fraction of missing information (BFMI). BFMI quantifies how well momentum resampling matches the marginal energy distribution. For more information on BFMI, see https://arxiv.org/pdf/1604.00695v1.pdf. The current advice is that values smaller than ...
def bfmi(energy): r"""Calculate the estimated Bayesian fraction of missing information (BFMI). BFMI quantifies how well momentum resampling matches the marginal energy distribution. For more information on BFMI, see https://arxiv.org/pdf/1604.00695v1.pdf. The current advice is that values smaller than ...
[ "r", "Calculate", "the", "estimated", "Bayesian", "fraction", "of", "missing", "information", "(", "BFMI", ")", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/stats/stats.py#L20-L45
[ "def", "bfmi", "(", "energy", ")", ":", "energy_mat", "=", "np", ".", "atleast_2d", "(", "energy", ")", "num", "=", "np", ".", "square", "(", "np", ".", "diff", "(", "energy_mat", ",", "axis", "=", "1", ")", ")", ".", "mean", "(", "axis", "=", ...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
compare
r"""Compare models based on WAIC or LOO cross validation. WAIC is Widely applicable information criterion, and LOO is leave-one-out (LOO) cross-validation. Read more theory here - in a paper by some of the leading authorities on model selection - dx.doi.org/10.1111/1467-9868.00353 Parameters -----...
arviz/stats/stats.py
def compare( dataset_dict, ic="waic", method="BB-pseudo-BMA", b_samples=1000, alpha=1, seed=None, scale="deviance", ): r"""Compare models based on WAIC or LOO cross validation. WAIC is Widely applicable information criterion, and LOO is leave-one-out (LOO) cross-validation. Read...
def compare( dataset_dict, ic="waic", method="BB-pseudo-BMA", b_samples=1000, alpha=1, seed=None, scale="deviance", ): r"""Compare models based on WAIC or LOO cross validation. WAIC is Widely applicable information criterion, and LOO is leave-one-out (LOO) cross-validation. Read...
[ "r", "Compare", "models", "based", "on", "WAIC", "or", "LOO", "cross", "validation", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/stats/stats.py#L48-L251
[ "def", "compare", "(", "dataset_dict", ",", "ic", "=", "\"waic\"", ",", "method", "=", "\"BB-pseudo-BMA\"", ",", "b_samples", "=", "1000", ",", "alpha", "=", "1", ",", "seed", "=", "None", ",", "scale", "=", "\"deviance\"", ",", ")", ":", "names", "=",...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
_ic_matrix
Store the previously computed pointwise predictive accuracy values (ics) in a 2D matrix.
arviz/stats/stats.py
def _ic_matrix(ics, ic_i): """Store the previously computed pointwise predictive accuracy values (ics) in a 2D matrix.""" cols, _ = ics.shape rows = len(ics[ic_i].iloc[0]) ic_i_val = np.zeros((rows, cols)) for idx, val in enumerate(ics.index): ic = ics.loc[val][ic_i] if len(ic) != ...
def _ic_matrix(ics, ic_i): """Store the previously computed pointwise predictive accuracy values (ics) in a 2D matrix.""" cols, _ = ics.shape rows = len(ics[ic_i].iloc[0]) ic_i_val = np.zeros((rows, cols)) for idx, val in enumerate(ics.index): ic = ics.loc[val][ic_i] if len(ic) != ...
[ "Store", "the", "previously", "computed", "pointwise", "predictive", "accuracy", "values", "(", "ics", ")", "in", "a", "2D", "matrix", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/stats/stats.py#L254-L268
[ "def", "_ic_matrix", "(", "ics", ",", "ic_i", ")", ":", "cols", ",", "_", "=", "ics", ".", "shape", "rows", "=", "len", "(", "ics", "[", "ic_i", "]", ".", "iloc", "[", "0", "]", ")", "ic_i_val", "=", "np", ".", "zeros", "(", "(", "rows", ",",...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
hpd
Calculate highest posterior density (HPD) of array for given credible_interval. The HPD is the minimum width Bayesian credible interval (BCI). This implementation works only for unimodal distributions. Parameters ---------- x : Numpy array An array containing posterior samples credible...
arviz/stats/stats.py
def hpd(x, credible_interval=0.94, circular=False): """ Calculate highest posterior density (HPD) of array for given credible_interval. The HPD is the minimum width Bayesian credible interval (BCI). This implementation works only for unimodal distributions. Parameters ---------- x : Numpy ...
def hpd(x, credible_interval=0.94, circular=False): """ Calculate highest posterior density (HPD) of array for given credible_interval. The HPD is the minimum width Bayesian credible interval (BCI). This implementation works only for unimodal distributions. Parameters ---------- x : Numpy ...
[ "Calculate", "highest", "posterior", "density", "(", "HPD", ")", "of", "array", "for", "given", "credible_interval", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/stats/stats.py#L271-L328
[ "def", "hpd", "(", "x", ",", "credible_interval", "=", "0.94", ",", "circular", "=", "False", ")", ":", "if", "x", ".", "ndim", ">", "1", ":", "hpd_array", "=", "np", ".", "array", "(", "[", "hpd", "(", "row", ",", "credible_interval", "=", "credib...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
_logsumexp
Stable logsumexp when b >= 0 and b is scalar. b_inv overwrites b unless b_inv is None.
arviz/stats/stats.py
def _logsumexp(ary, *, b=None, b_inv=None, axis=None, keepdims=False, out=None, copy=True): """Stable logsumexp when b >= 0 and b is scalar. b_inv overwrites b unless b_inv is None. """ # check dimensions for result arrays ary = np.asarray(ary) if ary.dtype.kind == "i": ary = ary.astype...
def _logsumexp(ary, *, b=None, b_inv=None, axis=None, keepdims=False, out=None, copy=True): """Stable logsumexp when b >= 0 and b is scalar. b_inv overwrites b unless b_inv is None. """ # check dimensions for result arrays ary = np.asarray(ary) if ary.dtype.kind == "i": ary = ary.astype...
[ "Stable", "logsumexp", "when", "b", ">", "=", "0", "and", "b", "is", "scalar", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/stats/stats.py#L331-L384
[ "def", "_logsumexp", "(", "ary", ",", "*", ",", "b", "=", "None", ",", "b_inv", "=", "None", ",", "axis", "=", "None", ",", "keepdims", "=", "False", ",", "out", "=", "None", ",", "copy", "=", "True", ")", ":", "# check dimensions for result arrays", ...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
loo
Pareto-smoothed importance sampling leave-one-out cross-validation. Calculates leave-one-out (LOO) cross-validation for out of sample predictive model fit, following Vehtari et al. (2017). Cross-validation is computed using Pareto-smoothed importance sampling (PSIS). Parameters ---------- data...
arviz/stats/stats.py
def loo(data, pointwise=False, reff=None, scale="deviance"): """Pareto-smoothed importance sampling leave-one-out cross-validation. Calculates leave-one-out (LOO) cross-validation for out of sample predictive model fit, following Vehtari et al. (2017). Cross-validation is computed using Pareto-smoothed ...
def loo(data, pointwise=False, reff=None, scale="deviance"): """Pareto-smoothed importance sampling leave-one-out cross-validation. Calculates leave-one-out (LOO) cross-validation for out of sample predictive model fit, following Vehtari et al. (2017). Cross-validation is computed using Pareto-smoothed ...
[ "Pareto", "-", "smoothed", "importance", "sampling", "leave", "-", "one", "-", "out", "cross", "-", "validation", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/stats/stats.py#L387-L490
[ "def", "loo", "(", "data", ",", "pointwise", "=", "False", ",", "reff", "=", "None", ",", "scale", "=", "\"deviance\"", ")", ":", "inference_data", "=", "convert_to_inference_data", "(", "data", ")", "for", "group", "in", "(", "\"posterior\"", ",", "\"samp...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
psislw
Pareto smoothed importance sampling (PSIS). Parameters ---------- log_weights : array Array of size (n_samples, n_observations) reff : float relative MCMC efficiency, `ess / n` Returns ------- lw_out : array Smoothed log weights kss : array Pareto tail i...
arviz/stats/stats.py
def psislw(log_weights, reff=1.0): """ Pareto smoothed importance sampling (PSIS). Parameters ---------- log_weights : array Array of size (n_samples, n_observations) reff : float relative MCMC efficiency, `ess / n` Returns ------- lw_out : array Smoothed lo...
def psislw(log_weights, reff=1.0): """ Pareto smoothed importance sampling (PSIS). Parameters ---------- log_weights : array Array of size (n_samples, n_observations) reff : float relative MCMC efficiency, `ess / n` Returns ------- lw_out : array Smoothed lo...
[ "Pareto", "smoothed", "importance", "sampling", "(", "PSIS", ")", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/stats/stats.py#L493-L561
[ "def", "psislw", "(", "log_weights", ",", "reff", "=", "1.0", ")", ":", "rows", ",", "cols", "=", "log_weights", ".", "shape", "log_weights_out", "=", "np", ".", "copy", "(", "log_weights", ",", "order", "=", "\"F\"", ")", "kss", "=", "np", ".", "emp...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
_gpdfit
Estimate the parameters for the Generalized Pareto Distribution (GPD). Empirical Bayes estimate for the parameters of the generalized Pareto distribution given the data. Parameters ---------- x : array sorted 1D data array Returns ------- k : float estimated shape para...
arviz/stats/stats.py
def _gpdfit(x): """Estimate the parameters for the Generalized Pareto Distribution (GPD). Empirical Bayes estimate for the parameters of the generalized Pareto distribution given the data. Parameters ---------- x : array sorted 1D data array Returns ------- k : float ...
def _gpdfit(x): """Estimate the parameters for the Generalized Pareto Distribution (GPD). Empirical Bayes estimate for the parameters of the generalized Pareto distribution given the data. Parameters ---------- x : array sorted 1D data array Returns ------- k : float ...
[ "Estimate", "the", "parameters", "for", "the", "Generalized", "Pareto", "Distribution", "(", "GPD", ")", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/stats/stats.py#L564-L611
[ "def", "_gpdfit", "(", "x", ")", ":", "prior_bs", "=", "3", "prior_k", "=", "10", "len_x", "=", "len", "(", "x", ")", "m_est", "=", "30", "+", "int", "(", "len_x", "**", "0.5", ")", "b_ary", "=", "1", "-", "np", ".", "sqrt", "(", "m_est", "/"...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
_gpinv
Inverse Generalized Pareto distribution function.
arviz/stats/stats.py
def _gpinv(probs, kappa, sigma): """Inverse Generalized Pareto distribution function.""" x = np.full_like(probs, np.nan) if sigma <= 0: return x ok = (probs > 0) & (probs < 1) if np.all(ok): if np.abs(kappa) < np.finfo(float).eps: x = -np.log1p(-probs) # pylint: disable=...
def _gpinv(probs, kappa, sigma): """Inverse Generalized Pareto distribution function.""" x = np.full_like(probs, np.nan) if sigma <= 0: return x ok = (probs > 0) & (probs < 1) if np.all(ok): if np.abs(kappa) < np.finfo(float).eps: x = -np.log1p(-probs) # pylint: disable=...
[ "Inverse", "Generalized", "Pareto", "distribution", "function", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/stats/stats.py#L614-L640
[ "def", "_gpinv", "(", "probs", ",", "kappa", ",", "sigma", ")", ":", "x", "=", "np", ".", "full_like", "(", "probs", ",", "np", ".", "nan", ")", "if", "sigma", "<=", "0", ":", "return", "x", "ok", "=", "(", "probs", ">", "0", ")", "&", "(", ...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
r2_score
R² for Bayesian regression models. Only valid for linear models. Parameters ---------- y_true: : array-like of shape = (n_samples) or (n_samples, n_outputs) Ground truth (correct) target values. y_pred : array-like of shape = (n_samples) or (n_samples, n_outputs) Estimated target values...
arviz/stats/stats.py
def r2_score(y_true, y_pred): """R² for Bayesian regression models. Only valid for linear models. Parameters ---------- y_true: : array-like of shape = (n_samples) or (n_samples, n_outputs) Ground truth (correct) target values. y_pred : array-like of shape = (n_samples) or (n_samples, n_out...
def r2_score(y_true, y_pred): """R² for Bayesian regression models. Only valid for linear models. Parameters ---------- y_true: : array-like of shape = (n_samples) or (n_samples, n_outputs) Ground truth (correct) target values. y_pred : array-like of shape = (n_samples) or (n_samples, n_out...
[ "R²", "for", "Bayesian", "regression", "models", ".", "Only", "valid", "for", "linear", "models", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/stats/stats.py#L643-L668
[ "def", "r2_score", "(", "y_true", ",", "y_pred", ")", ":", "if", "y_pred", ".", "ndim", "==", "1", ":", "var_y_est", "=", "np", ".", "var", "(", "y_pred", ")", "var_e", "=", "np", ".", "var", "(", "y_true", "-", "y_pred", ")", "else", ":", "var_y...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
summary
Create a data frame with summary statistics. Parameters ---------- data : obj Any object that can be converted to an az.InferenceData object Refer to documentation of az.convert_to_dataset for details var_names : list Names of variables to include in summary include_circ : b...
arviz/stats/stats.py
def summary( data, var_names=None, fmt="wide", round_to=2, include_circ=None, stat_funcs=None, extend=True, credible_interval=0.94, order="C", ): """Create a data frame with summary statistics. Parameters ---------- data : obj Any object that can be converted...
def summary( data, var_names=None, fmt="wide", round_to=2, include_circ=None, stat_funcs=None, extend=True, credible_interval=0.94, order="C", ): """Create a data frame with summary statistics. Parameters ---------- data : obj Any object that can be converted...
[ "Create", "a", "data", "frame", "with", "summary", "statistics", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/stats/stats.py#L671-L894
[ "def", "summary", "(", "data", ",", "var_names", "=", "None", ",", "fmt", "=", "\"wide\"", ",", "round_to", "=", "2", ",", "include_circ", "=", "None", ",", "stat_funcs", "=", "None", ",", "extend", "=", "True", ",", "credible_interval", "=", "0.94", "...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
_make_ufunc
Make ufunc from function.
arviz/stats/stats.py
def _make_ufunc(func, index=Ellipsis, **kwargs): # noqa: D202 """Make ufunc from function.""" def _ufunc(ary): target = np.empty(ary.shape[:-2]) for idx in np.ndindex(target.shape): target[idx] = np.asarray(func(ary[idx].ravel(), **kwargs))[index] return target return ...
def _make_ufunc(func, index=Ellipsis, **kwargs): # noqa: D202 """Make ufunc from function.""" def _ufunc(ary): target = np.empty(ary.shape[:-2]) for idx in np.ndindex(target.shape): target[idx] = np.asarray(func(ary[idx].ravel(), **kwargs))[index] return target return ...
[ "Make", "ufunc", "from", "function", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/stats/stats.py#L897-L906
[ "def", "_make_ufunc", "(", "func", ",", "index", "=", "Ellipsis", ",", "*", "*", "kwargs", ")", ":", "# noqa: D202", "def", "_ufunc", "(", "ary", ")", ":", "target", "=", "np", ".", "empty", "(", "ary", ".", "shape", "[", ":", "-", "2", "]", ")",...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
_mc_error
Calculate the simulation standard error, accounting for non-independent samples. The trace is divided into batches, and the standard deviation of the batch means is calculated. Parameters ---------- x : Numpy array An array containing MCMC samples batches : integer Number of ba...
arviz/stats/stats.py
def _mc_error(x, batches=5, circular=False): """Calculate the simulation standard error, accounting for non-independent samples. The trace is divided into batches, and the standard deviation of the batch means is calculated. Parameters ---------- x : Numpy array An array containing MCM...
def _mc_error(x, batches=5, circular=False): """Calculate the simulation standard error, accounting for non-independent samples. The trace is divided into batches, and the standard deviation of the batch means is calculated. Parameters ---------- x : Numpy array An array containing MCM...
[ "Calculate", "the", "simulation", "standard", "error", "accounting", "for", "non", "-", "independent", "samples", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/stats/stats.py#L909-L954
[ "def", "_mc_error", "(", "x", ",", "batches", "=", "5", ",", "circular", "=", "False", ")", ":", "if", "x", ".", "ndim", ">", "1", ":", "dims", "=", "np", ".", "shape", "(", "x", ")", "trace", "=", "np", ".", "transpose", "(", "[", "t", ".", ...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
waic
Calculate the widely available information criterion. Also calculates the WAIC's standard error and the effective number of parameters of the samples in trace from model. Read more theory here - in a paper by some of the leading authorities on model selection dx.doi.org/10.1111/1467-9868.00353 Par...
arviz/stats/stats.py
def waic(data, pointwise=False, scale="deviance"): """Calculate the widely available information criterion. Also calculates the WAIC's standard error and the effective number of parameters of the samples in trace from model. Read more theory here - in a paper by some of the leading authorities on model...
def waic(data, pointwise=False, scale="deviance"): """Calculate the widely available information criterion. Also calculates the WAIC's standard error and the effective number of parameters of the samples in trace from model. Read more theory here - in a paper by some of the leading authorities on model...
[ "Calculate", "the", "widely", "available", "information", "criterion", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/stats/stats.py#L957-L1047
[ "def", "waic", "(", "data", ",", "pointwise", "=", "False", ",", "scale", "=", "\"deviance\"", ")", ":", "inference_data", "=", "convert_to_inference_data", "(", "data", ")", "for", "group", "in", "(", "\"sample_stats\"", ",", ")", ":", "if", "not", "hasat...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
plot_violin
Plot posterior of traces as violin plot. Notes ----- If multiple chains are provided for a variable they will be combined Parameters ---------- data : obj Any object that can be converted to an az.InferenceData object Refer to documentation of az.convert_to_dataset for details ...
arviz/plots/violinplot.py
def plot_violin( data, var_names=None, quartiles=True, credible_interval=0.94, shade=0.35, bw=4.5, sharey=True, figsize=None, textsize=None, ax=None, kwargs_shade=None, ): """Plot posterior of traces as violin plot. Notes ----- If multiple chains are provided...
def plot_violin( data, var_names=None, quartiles=True, credible_interval=0.94, shade=0.35, bw=4.5, sharey=True, figsize=None, textsize=None, ax=None, kwargs_shade=None, ): """Plot posterior of traces as violin plot. Notes ----- If multiple chains are provided...
[ "Plot", "posterior", "of", "traces", "as", "violin", "plot", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/plots/violinplot.py#L12-L113
[ "def", "plot_violin", "(", "data", ",", "var_names", "=", "None", ",", "quartiles", "=", "True", ",", "credible_interval", "=", "0.94", ",", "shade", "=", "0.35", ",", "bw", "=", "4.5", ",", "sharey", "=", "True", ",", "figsize", "=", "None", ",", "t...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
_violinplot
Auxiliary function to plot violinplots.
arviz/plots/violinplot.py
def _violinplot(val, shade, bw, ax, **kwargs_shade): """Auxiliary function to plot violinplots.""" density, low_b, up_b = _fast_kde(val, bw=bw) x = np.linspace(low_b, up_b, len(density)) x = np.concatenate([x, x[::-1]]) density = np.concatenate([-density, density[::-1]]) ax.fill_betweenx(x, de...
def _violinplot(val, shade, bw, ax, **kwargs_shade): """Auxiliary function to plot violinplots.""" density, low_b, up_b = _fast_kde(val, bw=bw) x = np.linspace(low_b, up_b, len(density)) x = np.concatenate([x, x[::-1]]) density = np.concatenate([-density, density[::-1]]) ax.fill_betweenx(x, de...
[ "Auxiliary", "function", "to", "plot", "violinplots", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/plots/violinplot.py#L116-L124
[ "def", "_violinplot", "(", "val", ",", "shade", ",", "bw", ",", "ax", ",", "*", "*", "kwargs_shade", ")", ":", "density", ",", "low_b", ",", "up_b", "=", "_fast_kde", "(", "val", ",", "bw", "=", "bw", ")", "x", "=", "np", ".", "linspace", "(", ...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
cat_hist
Auxiliary function to plot discrete-violinplots.
arviz/plots/violinplot.py
def cat_hist(val, shade, ax, **kwargs_shade): """Auxiliary function to plot discrete-violinplots.""" bins = get_bins(val) binned_d, _ = np.histogram(val, bins=bins, normed=True) bin_edges = np.linspace(np.min(val), np.max(val), len(bins)) centers = 0.5 * (bin_edges + np.roll(bin_edges, 1))[:-1] ...
def cat_hist(val, shade, ax, **kwargs_shade): """Auxiliary function to plot discrete-violinplots.""" bins = get_bins(val) binned_d, _ = np.histogram(val, bins=bins, normed=True) bin_edges = np.linspace(np.min(val), np.max(val), len(bins)) centers = 0.5 * (bin_edges + np.roll(bin_edges, 1))[:-1] ...
[ "Auxiliary", "function", "to", "plot", "discrete", "-", "violinplots", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/plots/violinplot.py#L127-L137
[ "def", "cat_hist", "(", "val", ",", "shade", ",", "ax", ",", "*", "*", "kwargs_shade", ")", ":", "bins", "=", "get_bins", "(", "val", ")", "binned_d", ",", "_", "=", "np", ".", "histogram", "(", "val", ",", "bins", "=", "bins", ",", "normed", "="...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
plot_joint
Plot a scatter or hexbin of two variables with their respective marginals distributions. Parameters ---------- data : obj Any object that can be converted to an az.InferenceData object Refer to documentation of az.convert_to_dataset for details var_names : Iter of 2 e.g. (var_1, var_2) ...
arviz/plots/jointplot.py
def plot_joint( data, var_names=None, coords=None, figsize=None, textsize=None, kind="scatter", gridsize="auto", contour=True, fill_last=True, joint_kwargs=None, marginal_kwargs=None, ): """ Plot a scatter or hexbin of two variables with their respective marginals dis...
def plot_joint( data, var_names=None, coords=None, figsize=None, textsize=None, kind="scatter", gridsize="auto", contour=True, fill_last=True, joint_kwargs=None, marginal_kwargs=None, ): """ Plot a scatter or hexbin of two variables with their respective marginals dis...
[ "Plot", "a", "scatter", "or", "hexbin", "of", "two", "variables", "with", "their", "respective", "marginals", "distributions", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/plots/jointplot.py#L11-L172
[ "def", "plot_joint", "(", "data", ",", "var_names", "=", "None", ",", "coords", "=", "None", ",", "figsize", "=", "None", ",", "textsize", "=", "None", ",", "kind", "=", "\"scatter\"", ",", "gridsize", "=", "\"auto\"", ",", "contour", "=", "True", ",",...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
plot_hpd
Plot hpd intervals for regression data. Parameters ---------- x : array-like Values to plot y : array-like values ​​from which to compute the hpd credible_interval : float, optional Credible interval to plot. Defaults to 0.94. color : str Color used for the limit...
arviz/plots/hpdplot.py
def plot_hpd( x, y, credible_interval=0.94, color="C1", circular=False, smooth=True, smooth_kwargs=None, fill_kwargs=None, plot_kwargs=None, ax=None, ): """ Plot hpd intervals for regression data. Parameters ---------- x : array-like Values to plot ...
def plot_hpd( x, y, credible_interval=0.94, color="C1", circular=False, smooth=True, smooth_kwargs=None, fill_kwargs=None, plot_kwargs=None, ax=None, ): """ Plot hpd intervals for regression data. Parameters ---------- x : array-like Values to plot ...
[ "Plot", "hpd", "intervals", "for", "regression", "data", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/plots/hpdplot.py#L10-L86
[ "def", "plot_hpd", "(", "x", ",", "y", ",", "credible_interval", "=", "0.94", ",", "color", "=", "\"C1\"", ",", "circular", "=", "False", ",", "smooth", "=", "True", ",", "smooth_kwargs", "=", "None", ",", "fill_kwargs", "=", "None", ",", "plot_kwargs", ...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
effective_sample_size
r"""Calculate estimate of the effective sample size. Parameters ---------- data : obj Any object that can be converted to an az.InferenceData object Refer to documentation of az.convert_to_dataset for details At least 2 posterior chains are needed to compute this diagnostic of one o...
arviz/stats/diagnostics.py
def effective_sample_size(data, *, var_names=None): r"""Calculate estimate of the effective sample size. Parameters ---------- data : obj Any object that can be converted to an az.InferenceData object Refer to documentation of az.convert_to_dataset for details At least 2 posteri...
def effective_sample_size(data, *, var_names=None): r"""Calculate estimate of the effective sample size. Parameters ---------- data : obj Any object that can be converted to an az.InferenceData object Refer to documentation of az.convert_to_dataset for details At least 2 posteri...
[ "r", "Calculate", "estimate", "of", "the", "effective", "sample", "size", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/stats/diagnostics.py#L16-L61
[ "def", "effective_sample_size", "(", "data", ",", "*", ",", "var_names", "=", "None", ")", ":", "if", "isinstance", "(", "data", ",", "np", ".", "ndarray", ")", ":", "return", "_get_ess", "(", "data", ")", "dataset", "=", "convert_to_dataset", "(", "data...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
_ess_ufunc
Ufunc for computing effective sample size. This can be used on an xarray Dataset, using `xr.apply_ufunc(_ess_ufunc, ..., input_core_dims=(('chain', 'draw'),))
arviz/stats/diagnostics.py
def _ess_ufunc(ary): """Ufunc for computing effective sample size. This can be used on an xarray Dataset, using `xr.apply_ufunc(_ess_ufunc, ..., input_core_dims=(('chain', 'draw'),)) """ target = np.empty(ary.shape[:-2]) for idx in np.ndindex(target.shape): target[idx] = _get_ess(ary[id...
def _ess_ufunc(ary): """Ufunc for computing effective sample size. This can be used on an xarray Dataset, using `xr.apply_ufunc(_ess_ufunc, ..., input_core_dims=(('chain', 'draw'),)) """ target = np.empty(ary.shape[:-2]) for idx in np.ndindex(target.shape): target[idx] = _get_ess(ary[id...
[ "Ufunc", "for", "computing", "effective", "sample", "size", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/stats/diagnostics.py#L64-L73
[ "def", "_ess_ufunc", "(", "ary", ")", ":", "target", "=", "np", ".", "empty", "(", "ary", ".", "shape", "[", ":", "-", "2", "]", ")", "for", "idx", "in", "np", ".", "ndindex", "(", "target", ".", "shape", ")", ":", "target", "[", "idx", "]", ...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
_get_ess
Compute the effective sample size for a 2D array.
arviz/stats/diagnostics.py
def _get_ess(sample_array): """Compute the effective sample size for a 2D array.""" shape = sample_array.shape if len(shape) != 2: raise TypeError("Effective sample size calculation requires 2 dimensional arrays.") n_chain, n_draws = shape if n_chain <= 1: raise TypeError("Effective ...
def _get_ess(sample_array): """Compute the effective sample size for a 2D array.""" shape = sample_array.shape if len(shape) != 2: raise TypeError("Effective sample size calculation requires 2 dimensional arrays.") n_chain, n_draws = shape if n_chain <= 1: raise TypeError("Effective ...
[ "Compute", "the", "effective", "sample", "size", "for", "a", "2D", "array", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/stats/diagnostics.py#L76-L124
[ "def", "_get_ess", "(", "sample_array", ")", ":", "shape", "=", "sample_array", ".", "shape", "if", "len", "(", "shape", ")", "!=", "2", ":", "raise", "TypeError", "(", "\"Effective sample size calculation requires 2 dimensional arrays.\"", ")", "n_chain", ",", "n...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
rhat
r"""Compute estimate of Split R-hat for a set of traces. The Split R-hat diagnostic tests for lack of convergence by comparing the variance between multiple chains to the variance within each chain. If convergence has been achieved, the between-chain and within-chain variances should be identical. To be mo...
arviz/stats/diagnostics.py
def rhat(data, var_names=None): r"""Compute estimate of Split R-hat for a set of traces. The Split R-hat diagnostic tests for lack of convergence by comparing the variance between multiple chains to the variance within each chain. If convergence has been achieved, the between-chain and within-chain var...
def rhat(data, var_names=None): r"""Compute estimate of Split R-hat for a set of traces. The Split R-hat diagnostic tests for lack of convergence by comparing the variance between multiple chains to the variance within each chain. If convergence has been achieved, the between-chain and within-chain var...
[ "r", "Compute", "estimate", "of", "Split", "R", "-", "hat", "for", "a", "set", "of", "traces", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/stats/diagnostics.py#L168-L217
[ "def", "rhat", "(", "data", ",", "var_names", "=", "None", ")", ":", "if", "isinstance", "(", "data", ",", "np", ".", "ndarray", ")", ":", "return", "_get_split_rhat", "(", "data", ")", "dataset", "=", "convert_to_dataset", "(", "data", ",", "group", "...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
_rhat_ufunc
Ufunc for computing effective sample size. This can be used on an xarray Dataset, using `xr.apply_ufunc(_neff_ufunc, ..., input_core_dims=(('chain', 'draw'),))
arviz/stats/diagnostics.py
def _rhat_ufunc(ary): """Ufunc for computing effective sample size. This can be used on an xarray Dataset, using `xr.apply_ufunc(_neff_ufunc, ..., input_core_dims=(('chain', 'draw'),)) """ target = np.empty(ary.shape[:-2]) for idx in np.ndindex(target.shape): target[idx] = _get_split_rh...
def _rhat_ufunc(ary): """Ufunc for computing effective sample size. This can be used on an xarray Dataset, using `xr.apply_ufunc(_neff_ufunc, ..., input_core_dims=(('chain', 'draw'),)) """ target = np.empty(ary.shape[:-2]) for idx in np.ndindex(target.shape): target[idx] = _get_split_rh...
[ "Ufunc", "for", "computing", "effective", "sample", "size", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/stats/diagnostics.py#L220-L229
[ "def", "_rhat_ufunc", "(", "ary", ")", ":", "target", "=", "np", ".", "empty", "(", "ary", ".", "shape", "[", ":", "-", "2", "]", ")", "for", "idx", "in", "np", ".", "ndindex", "(", "target", ".", "shape", ")", ":", "target", "[", "idx", "]", ...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
_get_split_rhat
Compute the split-rhat for a 2d array.
arviz/stats/diagnostics.py
def _get_split_rhat(values, round_to=2): """Compute the split-rhat for a 2d array.""" shape = values.shape if len(shape) != 2: raise TypeError("Effective sample size calculation requires 2 dimensional arrays.") _, num_samples = shape num_split = num_samples // 2 # Calculate split chain m...
def _get_split_rhat(values, round_to=2): """Compute the split-rhat for a 2d array.""" shape = values.shape if len(shape) != 2: raise TypeError("Effective sample size calculation requires 2 dimensional arrays.") _, num_samples = shape num_split = num_samples // 2 # Calculate split chain m...
[ "Compute", "the", "split", "-", "rhat", "for", "a", "2d", "array", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/stats/diagnostics.py#L232-L256
[ "def", "_get_split_rhat", "(", "values", ",", "round_to", "=", "2", ")", ":", "shape", "=", "values", ".", "shape", "if", "len", "(", "shape", ")", "!=", "2", ":", "raise", "TypeError", "(", "\"Effective sample size calculation requires 2 dimensional arrays.\"", ...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
geweke
r"""Compute z-scores for convergence diagnostics. Compare the mean of the first % of series with the mean of the last % of series. x is divided into a number of segments for which this difference is computed. If the series is converged, this score should oscillate between -1 and 1. Parameters ----...
arviz/stats/diagnostics.py
def geweke(values, first=0.1, last=0.5, intervals=20): r"""Compute z-scores for convergence diagnostics. Compare the mean of the first % of series with the mean of the last % of series. x is divided into a number of segments for which this difference is computed. If the series is converged, this score ...
def geweke(values, first=0.1, last=0.5, intervals=20): r"""Compute z-scores for convergence diagnostics. Compare the mean of the first % of series with the mean of the last % of series. x is divided into a number of segments for which this difference is computed. If the series is converged, this score ...
[ "r", "Compute", "z", "-", "scores", "for", "convergence", "diagnostics", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/stats/diagnostics.py#L259-L328
[ "def", "geweke", "(", "values", ",", "first", "=", "0.1", ",", "last", "=", "0.5", ",", "intervals", "=", "20", ")", ":", "# Filter out invalid intervals", "for", "interval", "in", "(", "first", ",", "last", ")", ":", "if", "interval", "<=", "0", "or",...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
ks_summary
Display a summary of Pareto tail indices. Parameters ---------- pareto_tail_indices : array Pareto tail indices. Returns ------- df_k : dataframe Dataframe containing k diagnostic values.
arviz/stats/diagnostics.py
def ks_summary(pareto_tail_indices): """Display a summary of Pareto tail indices. Parameters ---------- pareto_tail_indices : array Pareto tail indices. Returns ------- df_k : dataframe Dataframe containing k diagnostic values. """ kcounts, _ = np.histogram(pareto_tail_...
def ks_summary(pareto_tail_indices): """Display a summary of Pareto tail indices. Parameters ---------- pareto_tail_indices : array Pareto tail indices. Returns ------- df_k : dataframe Dataframe containing k diagnostic values. """ kcounts, _ = np.histogram(pareto_tail_...
[ "Display", "a", "summary", "of", "Pareto", "tail", "indices", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/stats/diagnostics.py#L331-L355
[ "def", "ks_summary", "(", "pareto_tail_indices", ")", ":", "kcounts", ",", "_", "=", "np", ".", "histogram", "(", "pareto_tail_indices", ",", "bins", "=", "[", "-", "np", ".", "Inf", ",", "0.5", ",", "0.7", ",", "1", ",", "np", ".", "Inf", "]", ")"...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
plot_trace
Plot distribution (histogram or kernel density estimates) and sampled values. If `divergences` data is available in `sample_stats`, will plot the location of divergences as dashed vertical lines. Parameters ---------- data : obj Any object that can be converted to an az.InferenceData objec...
arviz/plots/traceplot.py
def plot_trace( data, var_names=None, coords=None, divergences="bottom", figsize=None, textsize=None, lines=None, combined=False, plot_kwargs=None, fill_kwargs=None, rug_kwargs=None, hist_kwargs=None, trace_kwargs=None, ): """Plot distribution (histogram or kernel...
def plot_trace( data, var_names=None, coords=None, divergences="bottom", figsize=None, textsize=None, lines=None, combined=False, plot_kwargs=None, fill_kwargs=None, rug_kwargs=None, hist_kwargs=None, trace_kwargs=None, ): """Plot distribution (histogram or kernel...
[ "Plot", "distribution", "(", "histogram", "or", "kernel", "density", "estimates", ")", "and", "sampled", "values", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/plots/traceplot.py#L11-L235
[ "def", "plot_trace", "(", "data", ",", "var_names", "=", "None", ",", "coords", "=", "None", ",", "divergences", "=", "\"bottom\"", ",", "figsize", "=", "None", ",", "textsize", "=", "None", ",", "lines", "=", "None", ",", "combined", "=", "False", ","...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
_histplot_op
Add a histogram for the data to the axes.
arviz/plots/traceplot.py
def _histplot_op(ax, data, **kwargs): """Add a histogram for the data to the axes.""" bins = get_bins(data) ax.hist(data, bins=bins, align="left", density=True, **kwargs) return ax
def _histplot_op(ax, data, **kwargs): """Add a histogram for the data to the axes.""" bins = get_bins(data) ax.hist(data, bins=bins, align="left", density=True, **kwargs) return ax
[ "Add", "a", "histogram", "for", "the", "data", "to", "the", "axes", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/plots/traceplot.py#L238-L242
[ "def", "_histplot_op", "(", "ax", ",", "data", ",", "*", "*", "kwargs", ")", ":", "bins", "=", "get_bins", "(", "data", ")", "ax", ".", "hist", "(", "data", ",", "bins", "=", "bins", ",", "align", "=", "\"left\"", ",", "density", "=", "True", ","...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
concat
Concatenate InferenceData objects on a group level. Supports only concatenating with independent unique groups. Parameters ---------- *args : InferenceData Variable length InferenceData list or Sequence of InferenceData. copy : bool If True, groups are copied to the new Inf...
arviz/data/inference_data.py
def concat(*args, copy=True, inplace=False): """Concatenate InferenceData objects on a group level. Supports only concatenating with independent unique groups. Parameters ---------- *args : InferenceData Variable length InferenceData list or Sequence of InferenceData. copy : bo...
def concat(*args, copy=True, inplace=False): """Concatenate InferenceData objects on a group level. Supports only concatenating with independent unique groups. Parameters ---------- *args : InferenceData Variable length InferenceData list or Sequence of InferenceData. copy : bo...
[ "Concatenate", "InferenceData", "objects", "on", "a", "group", "level", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/inference_data.py#L103-L193
[ "def", "concat", "(", "*", "args", ",", "copy", "=", "True", ",", "inplace", "=", "False", ")", ":", "if", "len", "(", "args", ")", "==", "0", ":", "return", "InferenceData", "(", ")", "if", "len", "(", "args", ")", "==", "1", "and", "isinstance"...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
InferenceData.from_netcdf
Initialize object from a netcdf file. Expects that the file will have groups, each of which can be loaded by xarray. Parameters ---------- filename : str location of netcdf file Returns ------- InferenceData object
arviz/data/inference_data.py
def from_netcdf(filename): """Initialize object from a netcdf file. Expects that the file will have groups, each of which can be loaded by xarray. Parameters ---------- filename : str location of netcdf file Returns ------- InferenceData obj...
def from_netcdf(filename): """Initialize object from a netcdf file. Expects that the file will have groups, each of which can be loaded by xarray. Parameters ---------- filename : str location of netcdf file Returns ------- InferenceData obj...
[ "Initialize", "object", "from", "a", "netcdf", "file", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/inference_data.py#L43-L64
[ "def", "from_netcdf", "(", "filename", ")", ":", "groups", "=", "{", "}", "with", "nc", ".", "Dataset", "(", "filename", ",", "mode", "=", "\"r\"", ")", "as", "data", ":", "data_groups", "=", "list", "(", "data", ".", "groups", ")", "for", "group", ...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
InferenceData.to_netcdf
Write InferenceData to file using netcdf4. Parameters ---------- filename : str Location to write to compress : bool Whether to compress result. Note this saves disk space, but may make saving and loading somewhat slower (default: True). Retu...
arviz/data/inference_data.py
def to_netcdf(self, filename, compress=True): """Write InferenceData to file using netcdf4. Parameters ---------- filename : str Location to write to compress : bool Whether to compress result. Note this saves disk space, but may make saving a...
def to_netcdf(self, filename, compress=True): """Write InferenceData to file using netcdf4. Parameters ---------- filename : str Location to write to compress : bool Whether to compress result. Note this saves disk space, but may make saving a...
[ "Write", "InferenceData", "to", "file", "using", "netcdf4", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/inference_data.py#L66-L95
[ "def", "to_netcdf", "(", "self", ",", "filename", ",", "compress", "=", "True", ")", ":", "mode", "=", "\"w\"", "# overwrite first, then append", "if", "self", ".", "_groups", ":", "# check's whether a group is present or not.", "for", "group", "in", "self", ".", ...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
from_dict
Convert Dictionary data into an InferenceData object. Parameters ---------- posterior : dict posterior_predictive : dict sample_stats : dict "log_likelihood" variable for stats needs to be here. prior : dict prior_predictive : dict observed_data : dict coords : dict[str, ite...
arviz/data/io_dict.py
def from_dict( posterior=None, *, posterior_predictive=None, sample_stats=None, prior=None, prior_predictive=None, sample_stats_prior=None, observed_data=None, coords=None, dims=None ): """Convert Dictionary data into an InferenceData object. Parameters ---------- ...
def from_dict( posterior=None, *, posterior_predictive=None, sample_stats=None, prior=None, prior_predictive=None, sample_stats_prior=None, observed_data=None, coords=None, dims=None ): """Convert Dictionary data into an InferenceData object. Parameters ---------- ...
[ "Convert", "Dictionary", "data", "into", "an", "InferenceData", "object", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_dict.py#L138-L181
[ "def", "from_dict", "(", "posterior", "=", "None", ",", "*", ",", "posterior_predictive", "=", "None", ",", "sample_stats", "=", "None", ",", "prior", "=", "None", ",", "prior_predictive", "=", "None", ",", "sample_stats_prior", "=", "None", ",", "observed_d...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
DictConverter.posterior_to_xarray
Convert posterior samples to xarray.
arviz/data/io_dict.py
def posterior_to_xarray(self): """Convert posterior samples to xarray.""" data = self.posterior if not isinstance(data, dict): raise TypeError("DictConverter.posterior is not a dictionary") if "log_likelihood" in data: warnings.warn( "log_likeliho...
def posterior_to_xarray(self): """Convert posterior samples to xarray.""" data = self.posterior if not isinstance(data, dict): raise TypeError("DictConverter.posterior is not a dictionary") if "log_likelihood" in data: warnings.warn( "log_likeliho...
[ "Convert", "posterior", "samples", "to", "xarray", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_dict.py#L38-L51
[ "def", "posterior_to_xarray", "(", "self", ")", ":", "data", "=", "self", ".", "posterior", "if", "not", "isinstance", "(", "data", ",", "dict", ")", ":", "raise", "TypeError", "(", "\"DictConverter.posterior is not a dictionary\"", ")", "if", "\"log_likelihood\""...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
DictConverter.sample_stats_to_xarray
Convert sample_stats samples to xarray.
arviz/data/io_dict.py
def sample_stats_to_xarray(self): """Convert sample_stats samples to xarray.""" data = self.sample_stats if not isinstance(data, dict): raise TypeError("DictConverter.sample_stats is not a dictionary") return dict_to_dataset(data, library=None, coords=self.coords, dims=self....
def sample_stats_to_xarray(self): """Convert sample_stats samples to xarray.""" data = self.sample_stats if not isinstance(data, dict): raise TypeError("DictConverter.sample_stats is not a dictionary") return dict_to_dataset(data, library=None, coords=self.coords, dims=self....
[ "Convert", "sample_stats", "samples", "to", "xarray", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_dict.py#L54-L60
[ "def", "sample_stats_to_xarray", "(", "self", ")", ":", "data", "=", "self", ".", "sample_stats", "if", "not", "isinstance", "(", "data", ",", "dict", ")", ":", "raise", "TypeError", "(", "\"DictConverter.sample_stats is not a dictionary\"", ")", "return", "dict_t...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
DictConverter.posterior_predictive_to_xarray
Convert posterior_predictive samples to xarray.
arviz/data/io_dict.py
def posterior_predictive_to_xarray(self): """Convert posterior_predictive samples to xarray.""" data = self.posterior_predictive if not isinstance(data, dict): raise TypeError("DictConverter.posterior_predictive is not a dictionary") return dict_to_dataset(data, library=None...
def posterior_predictive_to_xarray(self): """Convert posterior_predictive samples to xarray.""" data = self.posterior_predictive if not isinstance(data, dict): raise TypeError("DictConverter.posterior_predictive is not a dictionary") return dict_to_dataset(data, library=None...
[ "Convert", "posterior_predictive", "samples", "to", "xarray", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_dict.py#L63-L69
[ "def", "posterior_predictive_to_xarray", "(", "self", ")", ":", "data", "=", "self", ".", "posterior_predictive", "if", "not", "isinstance", "(", "data", ",", "dict", ")", ":", "raise", "TypeError", "(", "\"DictConverter.posterior_predictive is not a dictionary\"", ")...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
DictConverter.prior_to_xarray
Convert prior samples to xarray.
arviz/data/io_dict.py
def prior_to_xarray(self): """Convert prior samples to xarray.""" data = self.prior if not isinstance(data, dict): raise TypeError("DictConverter.prior is not a dictionary") return dict_to_dataset(data, library=None, coords=self.coords, dims=self.dims)
def prior_to_xarray(self): """Convert prior samples to xarray.""" data = self.prior if not isinstance(data, dict): raise TypeError("DictConverter.prior is not a dictionary") return dict_to_dataset(data, library=None, coords=self.coords, dims=self.dims)
[ "Convert", "prior", "samples", "to", "xarray", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_dict.py#L72-L78
[ "def", "prior_to_xarray", "(", "self", ")", ":", "data", "=", "self", ".", "prior", "if", "not", "isinstance", "(", "data", ",", "dict", ")", ":", "raise", "TypeError", "(", "\"DictConverter.prior is not a dictionary\"", ")", "return", "dict_to_dataset", "(", ...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
DictConverter.sample_stats_prior_to_xarray
Convert sample_stats_prior samples to xarray.
arviz/data/io_dict.py
def sample_stats_prior_to_xarray(self): """Convert sample_stats_prior samples to xarray.""" data = self.sample_stats_prior if not isinstance(data, dict): raise TypeError("DictConverter.sample_stats_prior is not a dictionary") return dict_to_dataset(data, library=None, coords...
def sample_stats_prior_to_xarray(self): """Convert sample_stats_prior samples to xarray.""" data = self.sample_stats_prior if not isinstance(data, dict): raise TypeError("DictConverter.sample_stats_prior is not a dictionary") return dict_to_dataset(data, library=None, coords...
[ "Convert", "sample_stats_prior", "samples", "to", "xarray", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_dict.py#L81-L87
[ "def", "sample_stats_prior_to_xarray", "(", "self", ")", ":", "data", "=", "self", ".", "sample_stats_prior", "if", "not", "isinstance", "(", "data", ",", "dict", ")", ":", "raise", "TypeError", "(", "\"DictConverter.sample_stats_prior is not a dictionary\"", ")", "...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
DictConverter.prior_predictive_to_xarray
Convert prior_predictive samples to xarray.
arviz/data/io_dict.py
def prior_predictive_to_xarray(self): """Convert prior_predictive samples to xarray.""" data = self.prior_predictive if not isinstance(data, dict): raise TypeError("DictConverter.prior_predictive is not a dictionary") return dict_to_dataset(data, library=None, coords=self.co...
def prior_predictive_to_xarray(self): """Convert prior_predictive samples to xarray.""" data = self.prior_predictive if not isinstance(data, dict): raise TypeError("DictConverter.prior_predictive is not a dictionary") return dict_to_dataset(data, library=None, coords=self.co...
[ "Convert", "prior_predictive", "samples", "to", "xarray", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_dict.py#L90-L96
[ "def", "prior_predictive_to_xarray", "(", "self", ")", ":", "data", "=", "self", ".", "prior_predictive", "if", "not", "isinstance", "(", "data", ",", "dict", ")", ":", "raise", "TypeError", "(", "\"DictConverter.prior_predictive is not a dictionary\"", ")", "return...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
DictConverter.observed_data_to_xarray
Convert observed_data to xarray.
arviz/data/io_dict.py
def observed_data_to_xarray(self): """Convert observed_data to xarray.""" data = self.observed_data if not isinstance(data, dict): raise TypeError("DictConverter.observed_data is not a dictionary") if self.dims is None: dims = {} else: dims = s...
def observed_data_to_xarray(self): """Convert observed_data to xarray.""" data = self.observed_data if not isinstance(data, dict): raise TypeError("DictConverter.observed_data is not a dictionary") if self.dims is None: dims = {} else: dims = s...
[ "Convert", "observed_data", "to", "xarray", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_dict.py#L99-L116
[ "def", "observed_data_to_xarray", "(", "self", ")", ":", "data", "=", "self", ".", "observed_data", "if", "not", "isinstance", "(", "data", ",", "dict", ")", ":", "raise", "TypeError", "(", "\"DictConverter.observed_data is not a dictionary\"", ")", "if", "self", ...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
plot_compare
Summary plot for model comparison. This plot is in the style of the one used in the book Statistical Rethinking (Chapter 6) by Richard McElreath. Notes ----- Defaults to comparing Widely Accepted Information Criterion (WAIC) if present in comp_df column, otherwise compares Leave-one-ou...
arviz/plots/compareplot.py
def plot_compare( comp_df, insample_dev=True, plot_standard_error=True, plot_ic_diff=True, figsize=None, textsize=None, plot_kwargs=None, ax=None, ): """ Summary plot for model comparison. This plot is in the style of the one used in the book Statistical Rethink...
def plot_compare( comp_df, insample_dev=True, plot_standard_error=True, plot_ic_diff=True, figsize=None, textsize=None, plot_kwargs=None, ax=None, ): """ Summary plot for model comparison. This plot is in the style of the one used in the book Statistical Rethink...
[ "Summary", "plot", "for", "model", "comparison", ".", "This", "plot", "is", "in", "the", "style", "of", "the", "one", "used", "in", "the", "book", "Statistical", "Rethinking", "(", "Chapter", "6", ")", "by", "Richard", "McElreath", ".", "Notes", "-----", ...
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/plots/compareplot.py#L7-L171
[ "def", "plot_compare", "(", "comp_df", ",", "insample_dev", "=", "True", ",", "plot_standard_error", "=", "True", ",", "plot_ic_diff", "=", "True", ",", "figsize", "=", "None", ",", "textsize", "=", "None", ",", "plot_kwargs", "=", "None", ",", "ax", "=", ...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
plot_parallel
Plot parallel coordinates plot showing posterior points with and without divergences. Described by https://arxiv.org/abs/1709.01449, suggested by Ari Hartikainen Parameters ---------- data : obj Any object that can be converted to an az.InferenceData object Refer to documentation of az...
arviz/plots/parallelplot.py
def plot_parallel( data, var_names=None, coords=None, figsize=None, textsize=None, legend=True, colornd="k", colord="C1", shadend=0.025, ax=None, norm_method=None, ): """ Plot parallel coordinates plot showing posterior points with and without divergences. Descri...
def plot_parallel( data, var_names=None, coords=None, figsize=None, textsize=None, legend=True, colornd="k", colord="C1", shadend=0.025, ax=None, norm_method=None, ): """ Plot parallel coordinates plot showing posterior points with and without divergences. Descri...
[ "Plot", "parallel", "coordinates", "plot", "showing", "posterior", "points", "with", "and", "without", "divergences", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/plots/parallelplot.py#L11-L135
[ "def", "plot_parallel", "(", "data", ",", "var_names", "=", "None", ",", "coords", "=", "None", ",", "figsize", "=", "None", ",", "textsize", "=", "None", ",", "legend", "=", "True", ",", "colornd", "=", "\"k\"", ",", "colord", "=", "\"C1\"", ",", "s...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
_process_configuration
Extract sampling information.
arviz/data/io_cmdstan.py
def _process_configuration(comments): """Extract sampling information.""" num_samples = None num_warmup = None save_warmup = None for comment in comments: comment = comment.strip("#").strip() if comment.startswith("num_samples"): num_samples = int(comment.strip("num_sampl...
def _process_configuration(comments): """Extract sampling information.""" num_samples = None num_warmup = None save_warmup = None for comment in comments: comment = comment.strip("#").strip() if comment.startswith("num_samples"): num_samples = int(comment.strip("num_sampl...
[ "Extract", "sampling", "information", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_cmdstan.py#L376-L397
[ "def", "_process_configuration", "(", "comments", ")", ":", "num_samples", "=", "None", "num_warmup", "=", "None", "save_warmup", "=", "None", "for", "comment", "in", "comments", ":", "comment", "=", "comment", ".", "strip", "(", "\"#\"", ")", ".", "strip", ...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
_read_output
Read CmdStan output.csv. Parameters ---------- path : str Returns ------- List[DataFrame, DataFrame, List[str], List[str], List[str]] pandas.DataFrame Sample data pandas.DataFrame Sample stats List[str] Configuration information ...
arviz/data/io_cmdstan.py
def _read_output(path): """Read CmdStan output.csv. Parameters ---------- path : str Returns ------- List[DataFrame, DataFrame, List[str], List[str], List[str]] pandas.DataFrame Sample data pandas.DataFrame Sample stats List[str] ...
def _read_output(path): """Read CmdStan output.csv. Parameters ---------- path : str Returns ------- List[DataFrame, DataFrame, List[str], List[str], List[str]] pandas.DataFrame Sample data pandas.DataFrame Sample stats List[str] ...
[ "Read", "CmdStan", "output", ".", "csv", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_cmdstan.py#L400-L568
[ "def", "_read_output", "(", "path", ")", ":", "chains", "=", "[", "]", "configuration_info", "=", "[", "]", "adaptation_info", "=", "[", "]", "timing_info", "=", "[", "]", "i", "=", "0", "# Read (first) configuration and adaption", "with", "open", "(", "path...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
_process_data_var
Transform datastring to key, values pair. All values are transformed to floating point values. Parameters ---------- string : str Returns ------- Tuple[Str, Str] key, values pair
arviz/data/io_cmdstan.py
def _process_data_var(string): """Transform datastring to key, values pair. All values are transformed to floating point values. Parameters ---------- string : str Returns ------- Tuple[Str, Str] key, values pair """ key, var = string.split("<-") if "structure" in ...
def _process_data_var(string): """Transform datastring to key, values pair. All values are transformed to floating point values. Parameters ---------- string : str Returns ------- Tuple[Str, Str] key, values pair """ key, var = string.split("<-") if "structure" in ...
[ "Transform", "datastring", "to", "key", "values", "pair", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_cmdstan.py#L571-L603
[ "def", "_process_data_var", "(", "string", ")", ":", "key", ",", "var", "=", "string", ".", "split", "(", "\"<-\"", ")", "if", "\"structure\"", "in", "var", ":", "var", ",", "dim", "=", "var", ".", "replace", "(", "\"structure(\"", ",", "\"\"", ")", ...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
_read_data
Read Rdump output and transform to Python dictionary. Parameters ---------- path : str Returns ------- Dict key, values pairs from Rdump formatted data.
arviz/data/io_cmdstan.py
def _read_data(path): """Read Rdump output and transform to Python dictionary. Parameters ---------- path : str Returns ------- Dict key, values pairs from Rdump formatted data. """ data = {} with open(path, "r") as f_obj: var = "" for line in f_obj: ...
def _read_data(path): """Read Rdump output and transform to Python dictionary. Parameters ---------- path : str Returns ------- Dict key, values pairs from Rdump formatted data. """ data = {} with open(path, "r") as f_obj: var = "" for line in f_obj: ...
[ "Read", "Rdump", "output", "and", "transform", "to", "Python", "dictionary", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_cmdstan.py#L606-L631
[ "def", "_read_data", "(", "path", ")", ":", "data", "=", "{", "}", "with", "open", "(", "path", ",", "\"r\"", ")", "as", "f_obj", ":", "var", "=", "\"\"", "for", "line", "in", "f_obj", ":", "if", "\"<-\"", "in", "line", ":", "if", "len", "(", "...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
_unpack_dataframes
Transform a list of pandas.DataFrames to dictionary containing ndarrays. Parameters ---------- dfs : List[pandas.DataFrame] Returns ------- Dict key, values pairs. Values are formatted to shape = (nchain, ndraws, *shape)
arviz/data/io_cmdstan.py
def _unpack_dataframes(dfs): """Transform a list of pandas.DataFrames to dictionary containing ndarrays. Parameters ---------- dfs : List[pandas.DataFrame] Returns ------- Dict key, values pairs. Values are formatted to shape = (nchain, ndraws, *shape) """ col_groups = defa...
def _unpack_dataframes(dfs): """Transform a list of pandas.DataFrames to dictionary containing ndarrays. Parameters ---------- dfs : List[pandas.DataFrame] Returns ------- Dict key, values pairs. Values are formatted to shape = (nchain, ndraws, *shape) """ col_groups = defa...
[ "Transform", "a", "list", "of", "pandas", ".", "DataFrames", "to", "dictionary", "containing", "ndarrays", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_cmdstan.py#L634-L668
[ "def", "_unpack_dataframes", "(", "dfs", ")", ":", "col_groups", "=", "defaultdict", "(", "list", ")", "columns", "=", "dfs", "[", "0", "]", ".", "columns", "for", "col", "in", "columns", ":", "key", ",", "", "*", "loc", "=", "col", ".", "split", "...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
from_cmdstan
Convert CmdStan data into an InferenceData object. Parameters ---------- posterior : List[str] List of paths to output.csv files. CSV file can be stacked csv containing all the chains cat output*.csv > combined_output.csv posterior_predictive : str, List[Str] Poste...
arviz/data/io_cmdstan.py
def from_cmdstan( posterior=None, *, posterior_predictive=None, prior=None, prior_predictive=None, observed_data=None, observed_data_var=None, log_likelihood=None, coords=None, dims=None ): """Convert CmdStan data into an InferenceData object. Parameters ---------- ...
def from_cmdstan( posterior=None, *, posterior_predictive=None, prior=None, prior_predictive=None, observed_data=None, observed_data_var=None, log_likelihood=None, coords=None, dims=None ): """Convert CmdStan data into an InferenceData object. Parameters ---------- ...
[ "Convert", "CmdStan", "data", "into", "an", "InferenceData", "object", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_cmdstan.py#L671-L730
[ "def", "from_cmdstan", "(", "posterior", "=", "None", ",", "*", ",", "posterior_predictive", "=", "None", ",", "prior", "=", "None", ",", "prior_predictive", "=", "None", ",", "observed_data", "=", "None", ",", "observed_data_var", "=", "None", ",", "log_lik...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
CmdStanConverter._parse_posterior
Read csv paths to list of dataframes.
arviz/data/io_cmdstan.py
def _parse_posterior(self): """Read csv paths to list of dataframes.""" paths = self.posterior_ if isinstance(paths, str): paths = [paths] chain_data = [] for path in paths: parsed_output = _read_output(path) for sample, sample_stats, config, a...
def _parse_posterior(self): """Read csv paths to list of dataframes.""" paths = self.posterior_ if isinstance(paths, str): paths = [paths] chain_data = [] for path in paths: parsed_output = _read_output(path) for sample, sample_stats, config, a...
[ "Read", "csv", "paths", "to", "list", "of", "dataframes", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_cmdstan.py#L101-L120
[ "def", "_parse_posterior", "(", "self", ")", ":", "paths", "=", "self", ".", "posterior_", "if", "isinstance", "(", "paths", ",", "str", ")", ":", "paths", "=", "[", "paths", "]", "chain_data", "=", "[", "]", "for", "path", "in", "paths", ":", "parse...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
CmdStanConverter._parse_prior
Read csv paths to list of dataframes.
arviz/data/io_cmdstan.py
def _parse_prior(self): """Read csv paths to list of dataframes.""" paths = self.prior_ if isinstance(paths, str): paths = [paths] chain_data = [] for path in paths: parsed_output = _read_output(path) for sample, sample_stats, config, adaptatio...
def _parse_prior(self): """Read csv paths to list of dataframes.""" paths = self.prior_ if isinstance(paths, str): paths = [paths] chain_data = [] for path in paths: parsed_output = _read_output(path) for sample, sample_stats, config, adaptatio...
[ "Read", "csv", "paths", "to", "list", "of", "dataframes", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_cmdstan.py#L123-L142
[ "def", "_parse_prior", "(", "self", ")", ":", "paths", "=", "self", ".", "prior_", "if", "isinstance", "(", "paths", ",", "str", ")", ":", "paths", "=", "[", "paths", "]", "chain_data", "=", "[", "]", "for", "path", "in", "paths", ":", "parsed_output...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
CmdStanConverter.posterior_to_xarray
Extract posterior samples from output csv.
arviz/data/io_cmdstan.py
def posterior_to_xarray(self): """Extract posterior samples from output csv.""" columns = self.posterior[0].columns # filter posterior_predictive and log_likelihood posterior_predictive = self.posterior_predictive if posterior_predictive is None or ( isinstance(poste...
def posterior_to_xarray(self): """Extract posterior samples from output csv.""" columns = self.posterior[0].columns # filter posterior_predictive and log_likelihood posterior_predictive = self.posterior_predictive if posterior_predictive is None or ( isinstance(poste...
[ "Extract", "posterior", "samples", "from", "output", "csv", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_cmdstan.py#L145-L175
[ "def", "posterior_to_xarray", "(", "self", ")", ":", "columns", "=", "self", ".", "posterior", "[", "0", "]", ".", "columns", "# filter posterior_predictive and log_likelihood", "posterior_predictive", "=", "self", ".", "posterior_predictive", "if", "posterior_predictiv...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
CmdStanConverter.sample_stats_to_xarray
Extract sample_stats from fit.
arviz/data/io_cmdstan.py
def sample_stats_to_xarray(self): """Extract sample_stats from fit.""" dtypes = {"divergent__": bool, "n_leapfrog__": np.int64, "treedepth__": np.int64} # copy dims and coords dims = deepcopy(self.dims) if self.dims is not None else {} coords = deepcopy(self.coords) if self.coor...
def sample_stats_to_xarray(self): """Extract sample_stats from fit.""" dtypes = {"divergent__": bool, "n_leapfrog__": np.int64, "treedepth__": np.int64} # copy dims and coords dims = deepcopy(self.dims) if self.dims is not None else {} coords = deepcopy(self.coords) if self.coor...
[ "Extract", "sample_stats", "from", "fit", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_cmdstan.py#L179-L231
[ "def", "sample_stats_to_xarray", "(", "self", ")", ":", "dtypes", "=", "{", "\"divergent__\"", ":", "bool", ",", "\"n_leapfrog__\"", ":", "np", ".", "int64", ",", "\"treedepth__\"", ":", "np", ".", "int64", "}", "# copy dims and coords", "dims", "=", "deepcopy...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
CmdStanConverter.posterior_predictive_to_xarray
Convert posterior_predictive samples to xarray.
arviz/data/io_cmdstan.py
def posterior_predictive_to_xarray(self): """Convert posterior_predictive samples to xarray.""" posterior_predictive = self.posterior_predictive columns = self.posterior[0].columns if ( isinstance(posterior_predictive, (tuple, list)) and posterior_predictive[0].en...
def posterior_predictive_to_xarray(self): """Convert posterior_predictive samples to xarray.""" posterior_predictive = self.posterior_predictive columns = self.posterior[0].columns if ( isinstance(posterior_predictive, (tuple, list)) and posterior_predictive[0].en...
[ "Convert", "posterior_predictive", "samples", "to", "xarray", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_cmdstan.py#L235-L260
[ "def", "posterior_predictive_to_xarray", "(", "self", ")", ":", "posterior_predictive", "=", "self", ".", "posterior_predictive", "columns", "=", "self", ".", "posterior", "[", "0", "]", ".", "columns", "if", "(", "isinstance", "(", "posterior_predictive", ",", ...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
CmdStanConverter.prior_to_xarray
Convert prior samples to xarray.
arviz/data/io_cmdstan.py
def prior_to_xarray(self): """Convert prior samples to xarray.""" # filter prior_predictive prior_predictive = self.prior_predictive columns = self.prior[0].columns if prior_predictive is None or ( isinstance(prior_predictive, str) and prior_predictive.lower().endswit...
def prior_to_xarray(self): """Convert prior samples to xarray.""" # filter prior_predictive prior_predictive = self.prior_predictive columns = self.prior[0].columns if prior_predictive is None or ( isinstance(prior_predictive, str) and prior_predictive.lower().endswit...
[ "Convert", "prior", "samples", "to", "xarray", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_cmdstan.py#L263-L284
[ "def", "prior_to_xarray", "(", "self", ")", ":", "# filter prior_predictive", "prior_predictive", "=", "self", ".", "prior_predictive", "columns", "=", "self", ".", "prior", "[", "0", "]", ".", "columns", "if", "prior_predictive", "is", "None", "or", "(", "isi...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
CmdStanConverter.sample_stats_prior_to_xarray
Extract sample_stats from fit.
arviz/data/io_cmdstan.py
def sample_stats_prior_to_xarray(self): """Extract sample_stats from fit.""" dtypes = {"divergent__": bool, "n_leapfrog__": np.int64, "treedepth__": np.int64} # copy dims and coords dims = deepcopy(self.dims) if self.dims is not None else {} coords = deepcopy(self.coords) if sel...
def sample_stats_prior_to_xarray(self): """Extract sample_stats from fit.""" dtypes = {"divergent__": bool, "n_leapfrog__": np.int64, "treedepth__": np.int64} # copy dims and coords dims = deepcopy(self.dims) if self.dims is not None else {} coords = deepcopy(self.coords) if sel...
[ "Extract", "sample_stats", "from", "fit", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_cmdstan.py#L288-L307
[ "def", "sample_stats_prior_to_xarray", "(", "self", ")", ":", "dtypes", "=", "{", "\"divergent__\"", ":", "bool", ",", "\"n_leapfrog__\"", ":", "np", ".", "int64", ",", "\"treedepth__\"", ":", "np", ".", "int64", "}", "# copy dims and coords", "dims", "=", "de...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
CmdStanConverter.prior_predictive_to_xarray
Convert prior_predictive samples to xarray.
arviz/data/io_cmdstan.py
def prior_predictive_to_xarray(self): """Convert prior_predictive samples to xarray.""" prior_predictive = self.prior_predictive if ( isinstance(prior_predictive, (tuple, list)) and prior_predictive[0].endswith(".csv") ) or (isinstance(prior_predictive, str) and prior_predic...
def prior_predictive_to_xarray(self): """Convert prior_predictive samples to xarray.""" prior_predictive = self.prior_predictive if ( isinstance(prior_predictive, (tuple, list)) and prior_predictive[0].endswith(".csv") ) or (isinstance(prior_predictive, str) and prior_predic...
[ "Convert", "prior_predictive", "samples", "to", "xarray", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_cmdstan.py#L311-L335
[ "def", "prior_predictive_to_xarray", "(", "self", ")", ":", "prior_predictive", "=", "self", ".", "prior_predictive", "if", "(", "isinstance", "(", "prior_predictive", ",", "(", "tuple", ",", "list", ")", ")", "and", "prior_predictive", "[", "0", "]", ".", "...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
CmdStanConverter.observed_data_to_xarray
Convert observed data to xarray.
arviz/data/io_cmdstan.py
def observed_data_to_xarray(self): """Convert observed data to xarray.""" observed_data_raw = _read_data(self.observed_data) variables = self.observed_data_var if isinstance(variables, str): variables = [variables] observed_data = {} for key, vals in observed_...
def observed_data_to_xarray(self): """Convert observed data to xarray.""" observed_data_raw = _read_data(self.observed_data) variables = self.observed_data_var if isinstance(variables, str): variables = [variables] observed_data = {} for key, vals in observed_...
[ "Convert", "observed", "data", "to", "xarray", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_cmdstan.py#L338-L354
[ "def", "observed_data_to_xarray", "(", "self", ")", ":", "observed_data_raw", "=", "_read_data", "(", "self", ".", "observed_data", ")", "variables", "=", "self", ".", "observed_data_var", "if", "isinstance", "(", "variables", ",", "str", ")", ":", "variables", ...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
get_draws
Extract draws from PyStan fit.
arviz/data/io_pystan.py
def get_draws(fit, variables=None, ignore=None): """Extract draws from PyStan fit.""" if ignore is None: ignore = [] if fit.mode == 1: msg = "Model in mode 'test_grad'. Sampling is not conducted." raise AttributeError(msg) if fit.mode == 2 or fit.sim.get("samples") is No...
def get_draws(fit, variables=None, ignore=None): """Extract draws from PyStan fit.""" if ignore is None: ignore = [] if fit.mode == 1: msg = "Model in mode 'test_grad'. Sampling is not conducted." raise AttributeError(msg) if fit.mode == 2 or fit.sim.get("samples") is No...
[ "Extract", "draws", "from", "PyStan", "fit", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_pystan.py#L329-L408
[ "def", "get_draws", "(", "fit", ",", "variables", "=", "None", ",", "ignore", "=", "None", ")", ":", "if", "ignore", "is", "None", ":", "ignore", "=", "[", "]", "if", "fit", ".", "mode", "==", "1", ":", "msg", "=", "\"Model in mode 'test_grad'. Samplin...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
get_sample_stats
Extract sample stats from PyStan fit.
arviz/data/io_pystan.py
def get_sample_stats(fit, log_likelihood=None): """Extract sample stats from PyStan fit.""" dtypes = {"divergent__": bool, "n_leapfrog__": np.int64, "treedepth__": np.int64} ndraws = [s - w for s, w in zip(fit.sim["n_save"], fit.sim["warmup2"])] extraction = OrderedDict() for chain, (pyhold...
def get_sample_stats(fit, log_likelihood=None): """Extract sample stats from PyStan fit.""" dtypes = {"divergent__": bool, "n_leapfrog__": np.int64, "treedepth__": np.int64} ndraws = [s - w for s, w in zip(fit.sim["n_save"], fit.sim["warmup2"])] extraction = OrderedDict() for chain, (pyhold...
[ "Extract", "sample", "stats", "from", "PyStan", "fit", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_pystan.py#L411-L443
[ "def", "get_sample_stats", "(", "fit", ",", "log_likelihood", "=", "None", ")", ":", "dtypes", "=", "{", "\"divergent__\"", ":", "bool", ",", "\"n_leapfrog__\"", ":", "np", ".", "int64", ",", "\"treedepth__\"", ":", "np", ".", "int64", "}", "ndraws", "=", ...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
get_draws_stan3
Extract draws from PyStan3 fit.
arviz/data/io_pystan.py
def get_draws_stan3(fit, model=None, variables=None, ignore=None): """Extract draws from PyStan3 fit.""" if ignore is None: ignore = [] dtypes = {} if model is not None: dtypes = infer_dtypes(fit, model) if variables is None: variables = fit.param_names elif ...
def get_draws_stan3(fit, model=None, variables=None, ignore=None): """Extract draws from PyStan3 fit.""" if ignore is None: ignore = [] dtypes = {} if model is not None: dtypes = infer_dtypes(fit, model) if variables is None: variables = fit.param_names elif ...
[ "Extract", "draws", "from", "PyStan3", "fit", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_pystan.py#L446-L476
[ "def", "get_draws_stan3", "(", "fit", ",", "model", "=", "None", ",", "variables", "=", "None", ",", "ignore", "=", "None", ")", ":", "if", "ignore", "is", "None", ":", "ignore", "=", "[", "]", "dtypes", "=", "{", "}", "if", "model", "is", "not", ...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
get_sample_stats_stan3
Extract sample stats from PyStan3 fit.
arviz/data/io_pystan.py
def get_sample_stats_stan3(fit, model=None, log_likelihood=None): """Extract sample stats from PyStan3 fit.""" dtypes = {"divergent__": bool, "n_leapfrog__": np.int64, "treedepth__": np.int64} data = OrderedDict() for key in fit.sample_and_sampler_param_names: new_shape = -1, fit.num_chai...
def get_sample_stats_stan3(fit, model=None, log_likelihood=None): """Extract sample stats from PyStan3 fit.""" dtypes = {"divergent__": bool, "n_leapfrog__": np.int64, "treedepth__": np.int64} data = OrderedDict() for key in fit.sample_and_sampler_param_names: new_shape = -1, fit.num_chai...
[ "Extract", "sample", "stats", "from", "PyStan3", "fit", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_pystan.py#L479-L500
[ "def", "get_sample_stats_stan3", "(", "fit", ",", "model", "=", "None", ",", "log_likelihood", "=", "None", ")", ":", "dtypes", "=", "{", "\"divergent__\"", ":", "bool", ",", "\"n_leapfrog__\"", ":", "np", ".", "int64", ",", "\"treedepth__\"", ":", "np", "...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
infer_dtypes
Infer dtypes from Stan model code. Function strips out generated quantities block and searchs for `int` dtypes after stripping out comments inside the block.
arviz/data/io_pystan.py
def infer_dtypes(fit, model=None): """Infer dtypes from Stan model code. Function strips out generated quantities block and searchs for `int` dtypes after stripping out comments inside the block. """ pattern_remove_comments = re.compile( r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\...
def infer_dtypes(fit, model=None): """Infer dtypes from Stan model code. Function strips out generated quantities block and searchs for `int` dtypes after stripping out comments inside the block. """ pattern_remove_comments = re.compile( r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\...
[ "Infer", "dtypes", "from", "Stan", "model", "code", ".", "Function", "strips", "out", "generated", "quantities", "block", "and", "searchs", "for", "int", "dtypes", "after", "stripping", "out", "comments", "inside", "the", "block", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_pystan.py#L503-L533
[ "def", "infer_dtypes", "(", "fit", ",", "model", "=", "None", ")", ":", "pattern_remove_comments", "=", "re", ".", "compile", "(", "r'//.*?$|/\\*.*?\\*/|\\'(?:\\\\.|[^\\\\\\'])*\\'|\"(?:\\\\.|[^\\\\\"])*\"'", ",", "re", ".", "DOTALL", "|", "re", ".", "MULTILINE", ")...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
from_pystan
Convert PyStan data into an InferenceData object. Parameters ---------- posterior : StanFit4Model or stan.fit.Fit PyStan fit object for posterior. posterior_predictive : str, a list of str Posterior predictive samples for the posterior. prior : StanFit4Model or stan.fit.Fit ...
arviz/data/io_pystan.py
def from_pystan( posterior=None, *, posterior_predictive=None, prior=None, prior_predictive=None, observed_data=None, log_likelihood=None, coords=None, dims=None, posterior_model=None, prior_model=None ): """Convert PyStan data into an InferenceData object. ...
def from_pystan( posterior=None, *, posterior_predictive=None, prior=None, prior_predictive=None, observed_data=None, log_likelihood=None, coords=None, dims=None, posterior_model=None, prior_model=None ): """Convert PyStan data into an InferenceData object. ...
[ "Convert", "PyStan", "data", "into", "an", "InferenceData", "object", ".", "Parameters", "----------", "posterior", ":", "StanFit4Model", "or", "stan", ".", "fit", ".", "Fit", "PyStan", "fit", "object", "for", "posterior", ".", "posterior_predictive", ":", "str"...
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_pystan.py#L537-L610
[ "def", "from_pystan", "(", "posterior", "=", "None", ",", "*", ",", "posterior_predictive", "=", "None", ",", "prior", "=", "None", ",", "prior_predictive", "=", "None", ",", "observed_data", "=", "None", ",", "log_likelihood", "=", "None", ",", "coords", ...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
PyStanConverter.posterior_to_xarray
Extract posterior samples from fit.
arviz/data/io_pystan.py
def posterior_to_xarray(self): """Extract posterior samples from fit.""" posterior = self.posterior # filter posterior_predictive and log_likelihood posterior_predictive = self.posterior_predictive if posterior_predictive is None: posterior_predictive = [] ...
def posterior_to_xarray(self): """Extract posterior samples from fit.""" posterior = self.posterior # filter posterior_predictive and log_likelihood posterior_predictive = self.posterior_predictive if posterior_predictive is None: posterior_predictive = [] ...
[ "Extract", "posterior", "samples", "from", "fit", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_pystan.py#L42-L61
[ "def", "posterior_to_xarray", "(", "self", ")", ":", "posterior", "=", "self", ".", "posterior", "# filter posterior_predictive and log_likelihood\r", "posterior_predictive", "=", "self", ".", "posterior_predictive", "if", "posterior_predictive", "is", "None", ":", "poste...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
PyStanConverter.sample_stats_to_xarray
Extract sample_stats from posterior.
arviz/data/io_pystan.py
def sample_stats_to_xarray(self): """Extract sample_stats from posterior.""" posterior = self.posterior # copy dims and coords dims = deepcopy(self.dims) if self.dims is not None else {} coords = deepcopy(self.coords) if self.coords is not None else {} # log_lik...
def sample_stats_to_xarray(self): """Extract sample_stats from posterior.""" posterior = self.posterior # copy dims and coords dims = deepcopy(self.dims) if self.dims is not None else {} coords = deepcopy(self.coords) if self.coords is not None else {} # log_lik...
[ "Extract", "sample_stats", "from", "posterior", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_pystan.py#L64-L80
[ "def", "sample_stats_to_xarray", "(", "self", ")", ":", "posterior", "=", "self", ".", "posterior", "# copy dims and coords\r", "dims", "=", "deepcopy", "(", "self", ".", "dims", ")", "if", "self", ".", "dims", "is", "not", "None", "else", "{", "}", "coord...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
PyStanConverter.posterior_predictive_to_xarray
Convert posterior_predictive samples to xarray.
arviz/data/io_pystan.py
def posterior_predictive_to_xarray(self): """Convert posterior_predictive samples to xarray.""" posterior = self.posterior posterior_predictive = self.posterior_predictive data = get_draws(posterior, variables=posterior_predictive) return dict_to_dataset(data, library=self.p...
def posterior_predictive_to_xarray(self): """Convert posterior_predictive samples to xarray.""" posterior = self.posterior posterior_predictive = self.posterior_predictive data = get_draws(posterior, variables=posterior_predictive) return dict_to_dataset(data, library=self.p...
[ "Convert", "posterior_predictive", "samples", "to", "xarray", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_pystan.py#L84-L89
[ "def", "posterior_predictive_to_xarray", "(", "self", ")", ":", "posterior", "=", "self", ".", "posterior", "posterior_predictive", "=", "self", ".", "posterior_predictive", "data", "=", "get_draws", "(", "posterior", ",", "variables", "=", "posterior_predictive", "...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
PyStanConverter.prior_to_xarray
Convert prior samples to xarray.
arviz/data/io_pystan.py
def prior_to_xarray(self): """Convert prior samples to xarray.""" prior = self.prior # filter posterior_predictive and log_likelihood prior_predictive = self.prior_predictive if prior_predictive is None: prior_predictive = [] elif isinstance(prior_predi...
def prior_to_xarray(self): """Convert prior samples to xarray.""" prior = self.prior # filter posterior_predictive and log_likelihood prior_predictive = self.prior_predictive if prior_predictive is None: prior_predictive = [] elif isinstance(prior_predi...
[ "Convert", "prior", "samples", "to", "xarray", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_pystan.py#L92-L105
[ "def", "prior_to_xarray", "(", "self", ")", ":", "prior", "=", "self", ".", "prior", "# filter posterior_predictive and log_likelihood\r", "prior_predictive", "=", "self", ".", "prior_predictive", "if", "prior_predictive", "is", "None", ":", "prior_predictive", "=", "...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
PyStanConverter.sample_stats_prior_to_xarray
Extract sample_stats_prior from prior.
arviz/data/io_pystan.py
def sample_stats_prior_to_xarray(self): """Extract sample_stats_prior from prior.""" prior = self.prior data = get_sample_stats(prior) return dict_to_dataset(data, library=self.pystan, coords=self.coords, dims=self.dims)
def sample_stats_prior_to_xarray(self): """Extract sample_stats_prior from prior.""" prior = self.prior data = get_sample_stats(prior) return dict_to_dataset(data, library=self.pystan, coords=self.coords, dims=self.dims)
[ "Extract", "sample_stats_prior", "from", "prior", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_pystan.py#L108-L112
[ "def", "sample_stats_prior_to_xarray", "(", "self", ")", ":", "prior", "=", "self", ".", "prior", "data", "=", "get_sample_stats", "(", "prior", ")", "return", "dict_to_dataset", "(", "data", ",", "library", "=", "self", ".", "pystan", ",", "coords", "=", ...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
PyStanConverter.prior_predictive_to_xarray
Convert prior_predictive samples to xarray.
arviz/data/io_pystan.py
def prior_predictive_to_xarray(self): """Convert prior_predictive samples to xarray.""" prior = self.prior prior_predictive = self.prior_predictive data = get_draws(prior, variables=prior_predictive) return dict_to_dataset(data, library=self.pystan, coords=self.coords, dims=...
def prior_predictive_to_xarray(self): """Convert prior_predictive samples to xarray.""" prior = self.prior prior_predictive = self.prior_predictive data = get_draws(prior, variables=prior_predictive) return dict_to_dataset(data, library=self.pystan, coords=self.coords, dims=...
[ "Convert", "prior_predictive", "samples", "to", "xarray", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_pystan.py#L116-L121
[ "def", "prior_predictive_to_xarray", "(", "self", ")", ":", "prior", "=", "self", ".", "prior", "prior_predictive", "=", "self", ".", "prior_predictive", "data", "=", "get_draws", "(", "prior", ",", "variables", "=", "prior_predictive", ")", "return", "dict_to_d...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
PyStan3Converter.posterior_to_xarray
Extract posterior samples from fit.
arviz/data/io_pystan.py
def posterior_to_xarray(self): """Extract posterior samples from fit.""" posterior = self.posterior posterior_model = self.posterior_model # filter posterior_predictive and log_likelihood posterior_predictive = self.posterior_predictive if posterior_predictive is No...
def posterior_to_xarray(self): """Extract posterior samples from fit.""" posterior = self.posterior posterior_model = self.posterior_model # filter posterior_predictive and log_likelihood posterior_predictive = self.posterior_predictive if posterior_predictive is No...
[ "Extract", "posterior", "samples", "from", "fit", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_pystan.py#L199-L219
[ "def", "posterior_to_xarray", "(", "self", ")", ":", "posterior", "=", "self", ".", "posterior", "posterior_model", "=", "self", ".", "posterior_model", "# filter posterior_predictive and log_likelihood\r", "posterior_predictive", "=", "self", ".", "posterior_predictive", ...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
PyStan3Converter.sample_stats_to_xarray
Extract sample_stats from posterior.
arviz/data/io_pystan.py
def sample_stats_to_xarray(self): """Extract sample_stats from posterior.""" posterior = self.posterior posterior_model = self.posterior_model # copy dims and coords dims = deepcopy(self.dims) if self.dims is not None else {} coords = deepcopy(self.coords) if self.c...
def sample_stats_to_xarray(self): """Extract sample_stats from posterior.""" posterior = self.posterior posterior_model = self.posterior_model # copy dims and coords dims = deepcopy(self.dims) if self.dims is not None else {} coords = deepcopy(self.coords) if self.c...
[ "Extract", "sample_stats", "from", "posterior", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_pystan.py#L222-L240
[ "def", "sample_stats_to_xarray", "(", "self", ")", ":", "posterior", "=", "self", ".", "posterior", "posterior_model", "=", "self", ".", "posterior_model", "# copy dims and coords\r", "dims", "=", "deepcopy", "(", "self", ".", "dims", ")", "if", "self", ".", "...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
PyStan3Converter.posterior_predictive_to_xarray
Convert posterior_predictive samples to xarray.
arviz/data/io_pystan.py
def posterior_predictive_to_xarray(self): """Convert posterior_predictive samples to xarray.""" posterior = self.posterior posterior_model = self.posterior_model posterior_predictive = self.posterior_predictive data = get_draws_stan3(posterior, model=posterior_model, variabl...
def posterior_predictive_to_xarray(self): """Convert posterior_predictive samples to xarray.""" posterior = self.posterior posterior_model = self.posterior_model posterior_predictive = self.posterior_predictive data = get_draws_stan3(posterior, model=posterior_model, variabl...
[ "Convert", "posterior_predictive", "samples", "to", "xarray", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_pystan.py#L244-L250
[ "def", "posterior_predictive_to_xarray", "(", "self", ")", ":", "posterior", "=", "self", ".", "posterior", "posterior_model", "=", "self", ".", "posterior_model", "posterior_predictive", "=", "self", ".", "posterior_predictive", "data", "=", "get_draws_stan3", "(", ...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
PyStan3Converter.prior_to_xarray
Convert prior samples to xarray.
arviz/data/io_pystan.py
def prior_to_xarray(self): """Convert prior samples to xarray.""" prior = self.prior prior_model = self.prior_model # filter posterior_predictive and log_likelihood prior_predictive = self.prior_predictive if prior_predictive is None: prior_predictive =...
def prior_to_xarray(self): """Convert prior samples to xarray.""" prior = self.prior prior_model = self.prior_model # filter posterior_predictive and log_likelihood prior_predictive = self.prior_predictive if prior_predictive is None: prior_predictive =...
[ "Convert", "prior", "samples", "to", "xarray", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_pystan.py#L253-L267
[ "def", "prior_to_xarray", "(", "self", ")", ":", "prior", "=", "self", ".", "prior", "prior_model", "=", "self", ".", "prior_model", "# filter posterior_predictive and log_likelihood\r", "prior_predictive", "=", "self", ".", "prior_predictive", "if", "prior_predictive",...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
PyStan3Converter.sample_stats_prior_to_xarray
Extract sample_stats_prior from prior.
arviz/data/io_pystan.py
def sample_stats_prior_to_xarray(self): """Extract sample_stats_prior from prior.""" prior = self.prior prior_model = self.prior_model data = get_sample_stats_stan3(prior, model=prior_model) return dict_to_dataset(data, library=self.stan, coords=self.coords, dims=self.dims)
def sample_stats_prior_to_xarray(self): """Extract sample_stats_prior from prior.""" prior = self.prior prior_model = self.prior_model data = get_sample_stats_stan3(prior, model=prior_model) return dict_to_dataset(data, library=self.stan, coords=self.coords, dims=self.dims)
[ "Extract", "sample_stats_prior", "from", "prior", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_pystan.py#L270-L275
[ "def", "sample_stats_prior_to_xarray", "(", "self", ")", ":", "prior", "=", "self", ".", "prior", "prior_model", "=", "self", ".", "prior_model", "data", "=", "get_sample_stats_stan3", "(", "prior", ",", "model", "=", "prior_model", ")", "return", "dict_to_datas...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
PyStan3Converter.prior_predictive_to_xarray
Convert prior_predictive samples to xarray.
arviz/data/io_pystan.py
def prior_predictive_to_xarray(self): """Convert prior_predictive samples to xarray.""" prior = self.prior prior_model = self.prior_model prior_predictive = self.prior_predictive data = get_draws_stan3(prior, model=prior_model, variables=prior_predictive) return dic...
def prior_predictive_to_xarray(self): """Convert prior_predictive samples to xarray.""" prior = self.prior prior_model = self.prior_model prior_predictive = self.prior_predictive data = get_draws_stan3(prior, model=prior_model, variables=prior_predictive) return dic...
[ "Convert", "prior_predictive", "samples", "to", "xarray", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_pystan.py#L279-L285
[ "def", "prior_predictive_to_xarray", "(", "self", ")", ":", "prior", "=", "self", ".", "prior", "prior_model", "=", "self", ".", "prior_model", "prior_predictive", "=", "self", ".", "prior_predictive", "data", "=", "get_draws_stan3", "(", "prior", ",", "model", ...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
PyStan3Converter.observed_data_to_xarray
Convert observed data to xarray.
arviz/data/io_pystan.py
def observed_data_to_xarray(self): """Convert observed data to xarray.""" posterior_model = self.posterior_model if self.dims is None: dims = {} else: dims = self.dims observed_names = self.observed_data if isinstance(observed_names, str): ...
def observed_data_to_xarray(self): """Convert observed data to xarray.""" posterior_model = self.posterior_model if self.dims is None: dims = {} else: dims = self.dims observed_names = self.observed_data if isinstance(observed_names, str): ...
[ "Convert", "observed", "data", "to", "xarray", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_pystan.py#L289-L307
[ "def", "observed_data_to_xarray", "(", "self", ")", ":", "posterior_model", "=", "self", ".", "posterior_model", "if", "self", ".", "dims", "is", "None", ":", "dims", "=", "{", "}", "else", ":", "dims", "=", "self", ".", "dims", "observed_names", "=", "s...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
_get_var_names
Extract latent and observed variable names from pyro.MCMC. Parameters ---------- posterior : pyro.MCMC Fitted MCMC object from Pyro Returns ------- list[str], list[str] observed and latent variable names from the MCMC trace.
arviz/data/io_pyro.py
def _get_var_names(posterior): """Extract latent and observed variable names from pyro.MCMC. Parameters ---------- posterior : pyro.MCMC Fitted MCMC object from Pyro Returns ------- list[str], list[str] observed and latent variable names from the MCMC trace. """ sample_...
def _get_var_names(posterior): """Extract latent and observed variable names from pyro.MCMC. Parameters ---------- posterior : pyro.MCMC Fitted MCMC object from Pyro Returns ------- list[str], list[str] observed and latent variable names from the MCMC trace. """ sample_...
[ "Extract", "latent", "and", "observed", "variable", "names", "from", "pyro", ".", "MCMC", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_pyro.py#L8-L25
[ "def", "_get_var_names", "(", "posterior", ")", ":", "sample_point", "=", "posterior", ".", "exec_traces", "[", "0", "]", "nodes", "=", "[", "node", "for", "node", "in", "sample_point", ".", "nodes", ".", "values", "(", ")", "if", "node", "[", "\"type\""...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
from_pyro
Convert pyro data into an InferenceData object. Parameters ---------- posterior : pyro.MCMC Fitted MCMC object from Pyro coords : dict[str] -> list[str] Map of dimensions to coordinates dims : dict[str] -> list[str] Map variable names to their coordinates
arviz/data/io_pyro.py
def from_pyro(posterior=None, *, coords=None, dims=None): """Convert pyro data into an InferenceData object. Parameters ---------- posterior : pyro.MCMC Fitted MCMC object from Pyro coords : dict[str] -> list[str] Map of dimensions to coordinates dims : dict[str] -> list[str] ...
def from_pyro(posterior=None, *, coords=None, dims=None): """Convert pyro data into an InferenceData object. Parameters ---------- posterior : pyro.MCMC Fitted MCMC object from Pyro coords : dict[str] -> list[str] Map of dimensions to coordinates dims : dict[str] -> list[str] ...
[ "Convert", "pyro", "data", "into", "an", "InferenceData", "object", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_pyro.py#L106-L118
[ "def", "from_pyro", "(", "posterior", "=", "None", ",", "*", ",", "coords", "=", "None", ",", "dims", "=", "None", ")", ":", "return", "PyroConverter", "(", "posterior", "=", "posterior", ",", "coords", "=", "coords", ",", "dims", "=", "dims", ")", "...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
PyroConverter.posterior_to_xarray
Convert the posterior to an xarray dataset.
arviz/data/io_pyro.py
def posterior_to_xarray(self): """Convert the posterior to an xarray dataset.""" # Do not make pyro a requirement from pyro.infer import EmpiricalMarginal try: # Try pyro>=0.3 release syntax data = { name: np.expand_dims(samples.enumerate_support().squeeze()...
def posterior_to_xarray(self): """Convert the posterior to an xarray dataset.""" # Do not make pyro a requirement from pyro.infer import EmpiricalMarginal try: # Try pyro>=0.3 release syntax data = { name: np.expand_dims(samples.enumerate_support().squeeze()...
[ "Convert", "the", "posterior", "to", "an", "xarray", "dataset", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/data/io_pyro.py#L51-L73
[ "def", "posterior_to_xarray", "(", "self", ")", ":", "# Do not make pyro a requirement", "from", "pyro", ".", "infer", "import", "EmpiricalMarginal", "try", ":", "# Try pyro>=0.3 release syntax", "data", "=", "{", "name", ":", "np", ".", "expand_dims", "(", "samples...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
plot_autocorr
Bar plot of the autocorrelation function for a sequence of data. Useful in particular for posteriors from MCMC samples which may display correlation. Parameters ---------- data : obj Any object that can be converted to an az.InferenceData object Refer to documentation of az.convert_to_...
arviz/plots/autocorrplot.py
def plot_autocorr(data, var_names=None, max_lag=100, combined=False, figsize=None, textsize=None): """Bar plot of the autocorrelation function for a sequence of data. Useful in particular for posteriors from MCMC samples which may display correlation. Parameters ---------- data : obj Any o...
def plot_autocorr(data, var_names=None, max_lag=100, combined=False, figsize=None, textsize=None): """Bar plot of the autocorrelation function for a sequence of data. Useful in particular for posteriors from MCMC samples which may display correlation. Parameters ---------- data : obj Any o...
[ "Bar", "plot", "of", "the", "autocorrelation", "function", "for", "a", "sequence", "of", "data", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/plots/autocorrplot.py#L16-L112
[ "def", "plot_autocorr", "(", "data", ",", "var_names", "=", "None", ",", "max_lag", "=", "100", ",", "combined", "=", "False", ",", "figsize", "=", "None", ",", "textsize", "=", "None", ")", ":", "data", "=", "convert_to_dataset", "(", "data", ",", "gr...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
plot_energy
Plot energy transition distribution and marginal energy distribution in HMC algorithms. This may help to diagnose poor exploration by gradient-based algorithms like HMC or NUTS. Parameters ---------- data : xarray dataset, or object that can be converted (must represent `sample_stats` and h...
arviz/plots/energyplot.py
def plot_energy( data, kind="kde", bfmi=True, figsize=None, legend=True, fill_alpha=(1, 0.75), fill_color=("C0", "C5"), bw=4.5, textsize=None, fill_kwargs=None, plot_kwargs=None, ax=None, ): """Plot energy transition distribution and marginal energy distribution in HM...
def plot_energy( data, kind="kde", bfmi=True, figsize=None, legend=True, fill_alpha=(1, 0.75), fill_color=("C0", "C5"), bw=4.5, textsize=None, fill_kwargs=None, plot_kwargs=None, ax=None, ): """Plot energy transition distribution and marginal energy distribution in HM...
[ "Plot", "energy", "transition", "distribution", "and", "marginal", "energy", "distribution", "in", "HMC", "algorithms", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/plots/energyplot.py#L11-L146
[ "def", "plot_energy", "(", "data", ",", "kind", "=", "\"kde\"", ",", "bfmi", "=", "True", ",", "figsize", "=", "None", ",", "legend", "=", "True", ",", "fill_alpha", "=", "(", "1", ",", "0.75", ")", ",", "fill_color", "=", "(", "\"C0\"", ",", "\"C5...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
pairwise
From itertools cookbook. [a, b, c, ...] -> (a, b), (b, c), ...
arviz/plots/forestplot.py
def pairwise(iterable): """From itertools cookbook. [a, b, c, ...] -> (a, b), (b, c), ...""" first, second = tee(iterable) next(second, None) return zip(first, second)
def pairwise(iterable): """From itertools cookbook. [a, b, c, ...] -> (a, b), (b, c), ...""" first, second = tee(iterable) next(second, None) return zip(first, second)
[ "From", "itertools", "cookbook", ".", "[", "a", "b", "c", "...", "]", "-", ">", "(", "a", "b", ")", "(", "b", "c", ")", "..." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/plots/forestplot.py#L16-L20
[ "def", "pairwise", "(", "iterable", ")", ":", "first", ",", "second", "=", "tee", "(", "iterable", ")", "next", "(", "second", ",", "None", ")", "return", "zip", "(", "first", ",", "second", ")" ]
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
plot_forest
Forest plot to compare credible intervals from a number of distributions. Generates a forest plot of 100*(credible_interval)% credible intervals from a trace or list of traces. Parameters ---------- data : obj or list[obj] Any object that can be converted to an az.InferenceData object ...
arviz/plots/forestplot.py
def plot_forest( data, kind="forestplot", model_names=None, var_names=None, combined=False, credible_interval=0.94, rope=None, quartiles=True, ess=False, r_hat=False, colors="cycle", textsize=None, linewidth=None, markersize=None, ridgeplot_alpha=None, rid...
def plot_forest( data, kind="forestplot", model_names=None, var_names=None, combined=False, credible_interval=0.94, rope=None, quartiles=True, ess=False, r_hat=False, colors="cycle", textsize=None, linewidth=None, markersize=None, ridgeplot_alpha=None, rid...
[ "Forest", "plot", "to", "compare", "credible", "intervals", "from", "a", "number", "of", "distributions", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/plots/forestplot.py#L23-L226
[ "def", "plot_forest", "(", "data", ",", "kind", "=", "\"forestplot\"", ",", "model_names", "=", "None", ",", "var_names", "=", "None", ",", "combined", "=", "False", ",", "credible_interval", "=", "0.94", ",", "rope", "=", "None", ",", "quartiles", "=", ...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
PlotHandler.make_plotters
Initialize an object for each variable to be plotted.
arviz/plots/forestplot.py
def make_plotters(self): """Initialize an object for each variable to be plotted.""" plotters, y = {}, 0 for var_name in self.var_names: plotters[var_name] = VarHandler( var_name, self.data, y, model_names=self.model_nam...
def make_plotters(self): """Initialize an object for each variable to be plotted.""" plotters, y = {}, 0 for var_name in self.var_names: plotters[var_name] = VarHandler( var_name, self.data, y, model_names=self.model_nam...
[ "Initialize", "an", "object", "for", "each", "variable", "to", "be", "plotted", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/plots/forestplot.py#L270-L283
[ "def", "make_plotters", "(", "self", ")", ":", "plotters", ",", "y", "=", "{", "}", ",", "0", "for", "var_name", "in", "self", ".", "var_names", ":", "plotters", "[", "var_name", "]", "=", "VarHandler", "(", "var_name", ",", "self", ".", "data", ",",...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
PlotHandler.labels_and_ticks
Collect labels and ticks from plotters.
arviz/plots/forestplot.py
def labels_and_ticks(self): """Collect labels and ticks from plotters.""" labels, idxs = [], [] for plotter in self.plotters.values(): sub_labels, sub_idxs, _, _ = plotter.labels_ticks_and_vals() labels.append(sub_labels) idxs.append(sub_idxs) return n...
def labels_and_ticks(self): """Collect labels and ticks from plotters.""" labels, idxs = [], [] for plotter in self.plotters.values(): sub_labels, sub_idxs, _, _ = plotter.labels_ticks_and_vals() labels.append(sub_labels) idxs.append(sub_idxs) return n...
[ "Collect", "labels", "and", "ticks", "from", "plotters", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/plots/forestplot.py#L285-L292
[ "def", "labels_and_ticks", "(", "self", ")", ":", "labels", ",", "idxs", "=", "[", "]", ",", "[", "]", "for", "plotter", "in", "self", ".", "plotters", ".", "values", "(", ")", ":", "sub_labels", ",", "sub_idxs", ",", "_", ",", "_", "=", "plotter",...
d04d8da07f029fd2931f48d2f7f324cf393e5277
train
PlotHandler.display_multiple_ropes
Display ROPE when more than one interval is provided.
arviz/plots/forestplot.py
def display_multiple_ropes(self, rope, ax, y, linewidth, rope_var): """Display ROPE when more than one interval is provided.""" vals = dict(rope[rope_var][0])["rope"] ax.plot( vals, (y + 0.05, y + 0.05), lw=linewidth * 2, color="C2", so...
def display_multiple_ropes(self, rope, ax, y, linewidth, rope_var): """Display ROPE when more than one interval is provided.""" vals = dict(rope[rope_var][0])["rope"] ax.plot( vals, (y + 0.05, y + 0.05), lw=linewidth * 2, color="C2", so...
[ "Display", "ROPE", "when", "more", "than", "one", "interval", "is", "provided", "." ]
arviz-devs/arviz
python
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/plots/forestplot.py#L294-L306
[ "def", "display_multiple_ropes", "(", "self", ",", "rope", ",", "ax", ",", "y", ",", "linewidth", ",", "rope_var", ")", ":", "vals", "=", "dict", "(", "rope", "[", "rope_var", "]", "[", "0", "]", ")", "[", "\"rope\"", "]", "ax", ".", "plot", "(", ...
d04d8da07f029fd2931f48d2f7f324cf393e5277