diff --git a/CHANGELOG.md b/CHANGELOG.md index ceb9b8e00..8eb58aef4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ ### Maintenance and fixes * Fix bug in predictions with models using HSGP (#780) +* Fix `get_model_covariates()` utility function (#801) +* Upgrade PyMC dependency to >= 5.13 (#803) +* Use `pm.compute_deterministics()` to compute deterministics when bayeux based samplers are used (#803) ### Documentation diff --git a/bambi/__init__.py b/bambi/__init__.py index 660d6724c..fdec8ec16 100644 --- a/bambi/__init__.py +++ b/bambi/__init__.py @@ -4,7 +4,7 @@ from pymc import math -from .backend import PyMCModel +from .backend import inference_methods, PyMCModel from .config import config from .data import clear_data_home, load_data from .families import Family, Likelihood, Link @@ -25,6 +25,7 @@ "Formula", "clear_data_home", "config", + "inference_methods", "load_data", "math", ] diff --git a/bambi/backend/__init__.py b/bambi/backend/__init__.py index 6ee2a4aa3..daef1924c 100644 --- a/bambi/backend/__init__.py +++ b/bambi/backend/__init__.py @@ -1,3 +1,4 @@ from .pymc import PyMCModel +from .inference_methods import inference_methods -__all__ = ["PyMCModel"] +__all__ = ["inference_methods", "PyMCModel"] diff --git a/bambi/backend/inference_methods.py b/bambi/backend/inference_methods.py new file mode 100644 index 000000000..900d9c262 --- /dev/null +++ b/bambi/backend/inference_methods.py @@ -0,0 +1,119 @@ +import importlib +import inspect +import operator + +import pymc as pm + + +class InferenceMethods: + """Obtain a dictionary of available inference methods for Bambi + models and or the default kwargs of each inference method. + """ + + def __init__(self): + # In order to access inference methods, a bayeux model must be initialized + self.bayeux_model = bayeux_model() + self.bayeux_methods = self._get_bayeux_methods(bayeux_model()) + self.pymc_methods = self._pymc_methods() + + def _get_bayeux_methods(self, model): + # Bambi only supports bayeux MCMC methods + mcmc_methods = model.methods.get("mcmc") + return {"mcmc": mcmc_methods} + + def _pymc_methods(self): + return {"mcmc": ["mcmc"], "vi": ["vi"]} + + def _remove_parameters(self, fn_signature_dict): + # Remove 'pm.sample' parameters that are irrelevant for Bambi users + params_to_remove = [ + "progressbar", + "progressbar_theme", + "var_names", + "nuts_sampler", + "return_inferencedata", + "idata_kwargs", + "callback", + "mp_ctx", + "model", + ] + return {k: v for k, v in fn_signature_dict.items() if k not in params_to_remove} + + def get_kwargs(self, method): + """Get the default kwargs for a given inference method. + + Parameters + ---------- + method : str + The name of the inference method. + + Returns + ------- + dict + The default kwargs for the inference method. + """ + if method in self.bayeux_methods.get("mcmc"): + bx_method = operator.attrgetter(method)( + self.bayeux_model.mcmc # pylint: disable=no-member + ) + return bx_method.get_kwargs() + elif method in self.pymc_methods.get("mcmc"): + return self._remove_parameters(get_default_signature(pm.sample)) + elif method in self.pymc_methods.get("vi"): + return get_default_signature(pm.ADVI.fit) + else: + raise ValueError( + f"Inference method '{method}' not found in the list of available" + " methods. Use `bmb.inference_methods.names` to list the available methods." + ) + + @property + def names(self): + return {"pymc": self.pymc_methods, "bayeux": self.bayeux_methods} + + +def bayeux_model(): + """Dummy bayeux model for obtaining inference methods. + + A dummy model is needed because algorithms are dynamically determined at + runtime, based on the libraries that are installed. A model can give + programmatic access to the available algorithms via the `methods` attribute. + + Returns + ------- + bayeux.Model + A dummy model with a simple quadratic likelihood function. + """ + if importlib.util.find_spec("bayeux") is None: + return {"mcmc": []} + + import bayeux as bx # pylint: disable=import-outside-toplevel + + return bx.Model(lambda x: -(x**2), 0.0) + + +def get_default_signature(fn): + """Get the default parameter values of a function. + + This function inspects the signature of the provided function and returns + a dictionary containing the default values of its parameters. + + Parameters + ---------- + fn : callable + The function for which default argument values are to be retrieved. + + Returns + ------- + dict + A dictionary mapping argument names to their default values. + + """ + defaults = {} + for key, val in inspect.signature(fn).parameters.items(): + if val.default is not inspect.Signature.empty: + defaults[key] = val.default + return defaults + + +inference_methods = InferenceMethods() diff --git a/bambi/backend/pymc.py b/bambi/backend/pymc.py index 82b646ebe..75a1fe318 100644 --- a/bambi/backend/pymc.py +++ b/bambi/backend/pymc.py @@ -1,5 +1,4 @@ import functools -import importlib import logging import operator import traceback @@ -14,6 +13,7 @@ import pytensor.tensor as pt from pytensor.tensor.special import softmax +from bambi.backend.inference_methods import inference_methods from bambi.backend.links import cloglog, identity, inverse_squared, logit, probit, arctan_2 from bambi.backend.model_components import ConstantComponent, DistributionalComponent from bambi.utils import get_aliased_name @@ -47,8 +47,8 @@ def __init__(self): self.model = None self.spec = None self.components = {} - self.bayeux_methods = _get_bayeux_methods() - self.pymc_methods = {"mcmc": ["mcmc"], "vi": ["vi"]} + self.bayeux_methods = inference_methods.names["bayeux"] + self.pymc_methods = inference_methods.names["pymc"] def build(self, spec): """Compile the PyMC model from an abstract model specification. @@ -253,8 +253,13 @@ def _run_mcmc( return idata def _clean_results(self, idata, omit_offsets, include_mean, idata_from): - for group in idata.groups(): + # Before doing anything, make sure we compute deterministics. + if idata_from == "bayeux": + idata.posterior = pm.compute_deterministics( + idata.posterior, model=self.model, merge_dataset=True, progressbar=False + ) + for group in idata.groups(): getattr(idata, group).attrs["modeling_interface"] = "bambi" getattr(idata, group).attrs["modeling_interface_version"] = __version__ @@ -262,36 +267,41 @@ def _clean_results(self, idata, omit_offsets, include_mean, idata_from): offset_vars = [var for var in idata.posterior.data_vars if var.endswith("_offset")] idata.posterior = idata.posterior.drop_vars(offset_vars) - # Drop variables and dimensions associated with LKJ prior - vars_to_drop = [var for var in idata.posterior.data_vars if var.startswith("_LKJ")] - dims_to_drop = [dim for dim in idata.posterior.dims if dim.startswith("_LKJ")] + # NOTE: + # This has not had an effect for a while since we haven't been supporting LKJ prior lately. - idata.posterior = idata.posterior.drop_vars(vars_to_drop) - idata.posterior = idata.posterior.drop_dims(dims_to_drop) + # Drop variables and dimensions associated with LKJ prior + # vars_to_drop = [var for var in idata.posterior.data_vars if var.startswith("_LKJ")] + # dims_to_drop = [dim for dim in idata.posterior.dims if dim.startswith("_LKJ")] + # idata.posterior = idata.posterior.drop_vars(vars_to_drop) + # idata.posterior = idata.posterior.drop_dims(dims_to_drop) dims_original = list(self.model.coords) # Identify bayeux idata and rename dims and coordinates to match PyMC model if idata_from == "bayeux": - pymc_model_dims = [dim for dim in dims_original if "_obs" not in dim] - bayeux_dims = [ - dim for dim in idata.posterior.dims if not dim.startswith(("chain", "draw")) - ] - cleaned_dims = dict(zip(bayeux_dims, pymc_model_dims)) + cleaned_dims = { + f"{dim}_0": dim + for dim in dims_original + if not dim.endswith("_obs") and f"{dim}_0" in idata.posterior.dims + } idata = idata.rename(cleaned_dims) - # Discard dims that are in the model but unused in the posterior + # Don't select dims that are in the model but unused in the posterior dims_original = [dim for dim in dims_original if dim in idata.posterior.dims] # This does not add any new coordinate, it just changes the order so the ones # ending in "__factor_dim" are placed after the others. - dims_group = [c for c in dims_original if c.endswith("__factor_dim")] + dims_group = [dim for dim in dims_original if dim.endswith("__factor_dim")] # Keep the original order in dims_original dims_original_set = set(dims_original) - set(dims_group) - dims_original = [c for c in dims_original if c in dims_original_set] + dims_original = [dim for dim in dims_original if dim in dims_original_set] dims_new = ["chain", "draw"] + dims_original + dims_group - idata.posterior = idata.posterior.transpose(*dims_new) + + # Drop unused dimensions before transposing + dims_to_drop = [dim for dim in idata.posterior.dims if dim not in dims_new] + idata.posterior = idata.posterior.drop_dims(dims_to_drop).transpose(*dims_new) # Compute the actual intercept in all distributional components that have an intercept for pymc_component in self.distributional_components.values(): @@ -338,8 +348,7 @@ def _run_laplace(self, draws, omit_offsets, include_mean): Mainly for pedagogical use, provides reasonable results for approximately Gaussian posteriors. The approximation can be very poor for some models - like hierarchical ones. Use ``mcmc``, ``vi``, or JAX based MCMC methods - for better approximations. + like hierarchical ones. Use MCMC or VI methods for better approximations. Parameters ---------- @@ -388,10 +397,6 @@ def constant_components(self): def distributional_components(self): return {k: v for k, v in self.components.items() if isinstance(v, DistributionalComponent)} - @property - def inference_methods(self): - return {"pymc": self.pymc_methods, "bayeux": self.bayeux_methods} - def _posterior_samples_to_idata(samples, model): """Create InferenceData from samples. @@ -431,22 +436,3 @@ def _posterior_samples_to_idata(samples, model): idata = pm.to_inference_data(pm.backends.base.MultiTrace([strace]), model=model) return idata - - -def _get_bayeux_methods(): - """Gets a dictionary of usable bayeux methods if the bayeux package is installed - within the user's environment. - - Returns - ------- - dict - A dict where the keys are the module names and the values are the methods - available in that module. - """ - if importlib.util.find_spec("bayeux") is None: - return {"mcmc": []} - - import bayeux as bx # pylint: disable=import-outside-toplevel - - # Dummy log density to get access to all methods - return bx.Model(lambda x: -(x**2), 0.0).methods diff --git a/bambi/backend/terms.py b/bambi/backend/terms.py index a33b40d64..ed2a2e02c 100644 --- a/bambi/backend/terms.py +++ b/bambi/backend/terms.py @@ -110,9 +110,13 @@ def build(self, spec): response_dims = list(spec.response_component.response_term.coords) dims = list(self.coords) + response_dims + coef = self.build_distribution(self.term.prior, label, dims=dims, **kwargs) + # Squeeze ensures we don't have a shape of (n, 1) when we mean (n, ) # This happens with categorical predictors with two levels and intercept. - coef = self.build_distribution(self.term.prior, label, dims=dims, **kwargs).squeeze() + # See https://github.com/pymc-devs/pymc/issues/7246 + if len(coef.shape.eval()) == 2 and coef.shape.eval()[-1] == 1: + coef = pt.specify_broadcastable(coef, 1).squeeze() coef = coef[self.term.group_index] return coef, predictor diff --git a/bambi/families/univariate.py b/bambi/families/univariate.py index fa45c43a2..93b91785e 100644 --- a/bambi/families/univariate.py +++ b/bambi/families/univariate.py @@ -403,7 +403,7 @@ def transform_backend_eta(eta, kwargs): def transform_backend_kwargs(kwargs): # P(Y = k) = F(threshold_k - eta) * \prod_{j=1}^{k-1}{1 - F(threshold_j - eta)} p = kwargs.pop("p") - n_columns = p.type.shape[-1] + n_columns = p.shape.eval()[-1] p = pt.concatenate( [ pt.shape_padright(p[..., 0]), diff --git a/bambi/interpret/utils.py b/bambi/interpret/utils.py index cbb7bde19..b06f97c11 100644 --- a/bambi/interpret/utils.py +++ b/bambi/interpret/utils.py @@ -258,6 +258,9 @@ def get_model_covariates(model: Model) -> np.ndarray: flatten_covariates = [item for sublist in covariates for item in sublist] + # Don't include non-covariate names (#797) + flatten_covariates = [name for name in flatten_covariates if name in model.data] + return np.unique(flatten_covariates) diff --git a/bambi/models.py b/bambi/models.py index ecb57700f..74286dbed 100644 --- a/bambi/models.py +++ b/bambi/models.py @@ -267,7 +267,7 @@ def fit( Finally, ``"laplace"``, in which case a Laplace approximation is used and is not recommended other than for pedagogical use. To get a list of JAX based inference methods, call - ``model.backend.inference_methods['bayeux']``. This will return a dictionary of the + ``bmb.inference_methods.names['bayeux']``. This will return a dictionary of the available methods such as ``blackjax_nuts``, ``numpyro_nuts``, among others. init : str Initialization method. Defaults to ``"auto"``. The available methods are: @@ -307,7 +307,7 @@ def fit( ------- An ArviZ ``InferenceData`` instance if inference_method is ``"mcmc"`` (default), "laplace", or one of the MCMC methods in - ``model.backend.inference_methods['bayeux']['mcmc]``. + ``bmb.inference_methods.names['bayeux']['mcmc]``. An ``Approximation`` object if ``"vi"``. """ method = kwargs.pop("method", None) diff --git a/docs/notebooks/alternative_samplers.ipynb b/docs/notebooks/alternative_samplers.ipynb index 24d610d96..7610df6d6 100644 --- a/docs/notebooks/alternative_samplers.ipynb +++ b/docs/notebooks/alternative_samplers.ipynb @@ -15,9 +15,17 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "WARNING (pytensor.tensor.blas): Using NumPy C-API based implementation for BLAS functions.\n" + ] + } + ], "source": [ "import arviz as az\n", "import bambi as bmb\n", @@ -62,7 +70,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 20, "metadata": {}, "outputs": [], "source": [ @@ -74,12 +82,12 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "We can call `model.backend.inference_methods` that returns a nested dictionary of the backends and list of inference methods." + "We can call `bmb.inference_methods.names` that returns a nested dictionary of the backends and list of inference methods." ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 27, "metadata": {}, "outputs": [ { @@ -100,47 +108,16 @@ " 'flowmc_realnvp_hmc',\n", " 'flowmc_realnvp_mala',\n", " 'numpyro_hmc',\n", - " 'numpyro_nuts'],\n", - " 'optimize': ['jaxopt_bfgs',\n", - " 'jaxopt_gradient_descent',\n", - " 'jaxopt_lbfgs',\n", - " 'jaxopt_nonlinear_cg',\n", - " 'optimistix_bfgs',\n", - " 'optimistix_chord',\n", - " 'optimistix_dogleg',\n", - " 'optimistix_gauss_newton',\n", - " 'optimistix_indirect_levenberg_marquardt',\n", - " 'optimistix_levenberg_marquardt',\n", - " 'optimistix_nelder_mead',\n", - " 'optimistix_newton',\n", - " 'optimistix_nonlinear_cg',\n", - " 'optax_adabelief',\n", - " 'optax_adafactor',\n", - " 'optax_adagrad',\n", - " 'optax_adam',\n", - " 'optax_adamw',\n", - " 'optax_adamax',\n", - " 'optax_amsgrad',\n", - " 'optax_fromage',\n", - " 'optax_lamb',\n", - " 'optax_lion',\n", - " 'optax_noisy_sgd',\n", - " 'optax_novograd',\n", - " 'optax_radam',\n", - " 'optax_rmsprop',\n", - " 'optax_sgd',\n", - " 'optax_sm3',\n", - " 'optax_yogi'],\n", - " 'vi': ['tfp_factored_surrogate_posterior']}}" + " 'numpyro_nuts']}}" ] }, - "execution_count": 4, + "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "methods = model.backend.inference_methods\n", + "methods = bmb.inference_methods.names\n", "methods" ] }, @@ -153,7 +130,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 28, "metadata": {}, "outputs": [ { @@ -162,7 +139,7 @@ "{'mcmc': ['mcmc'], 'vi': ['vi']}" ] }, - "execution_count": 5, + "execution_count": 28, "metadata": {}, "output_type": "execute_result" } @@ -180,36 +157,36 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "['tfp_hmc',\n", - " 'tfp_nuts',\n", - " 'tfp_snaper_hmc',\n", - " 'blackjax_hmc',\n", - " 'blackjax_chees_hmc',\n", - " 'blackjax_meads_hmc',\n", - " 'blackjax_nuts',\n", - " 'blackjax_hmc_pathfinder',\n", - " 'blackjax_nuts_pathfinder',\n", - " 'flowmc_rqspline_hmc',\n", - " 'flowmc_rqspline_mala',\n", - " 'flowmc_realnvp_hmc',\n", - " 'flowmc_realnvp_mala',\n", - " 'numpyro_hmc',\n", - " 'numpyro_nuts']" + "{'mcmc': ['tfp_hmc',\n", + " 'tfp_nuts',\n", + " 'tfp_snaper_hmc',\n", + " 'blackjax_hmc',\n", + " 'blackjax_chees_hmc',\n", + " 'blackjax_meads_hmc',\n", + " 'blackjax_nuts',\n", + " 'blackjax_hmc_pathfinder',\n", + " 'blackjax_nuts_pathfinder',\n", + " 'flowmc_rqspline_hmc',\n", + " 'flowmc_rqspline_mala',\n", + " 'flowmc_realnvp_hmc',\n", + " 'flowmc_realnvp_mala',\n", + " 'numpyro_hmc',\n", + " 'numpyro_nuts']}" ] }, - "execution_count": 7, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "methods[\"bayeux\"][\"mcmc\"]" + "methods[\"bayeux\"]" ] }, { @@ -242,9 +219,46 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 7, "metadata": {}, "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "909c6a6f539145ab8348ebdeb1d42a3b", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Output()" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
\n" + ], + "text/plain": [] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "\n", + "\n" + ], + "text/plain": [ + "\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, { "data": { "text/html": [ @@ -256,8 +270,8 @@ "
<xarray.Dataset>\n", + "<xarray.Dataset> Size: 100kB\n", "Dimensions: (chain: 8, draw: 500)\n", "Coordinates:\n", - " * chain (chain) int64 0 1 2 3 4 5 6 7\n", - " * draw (draw) int64 0 1 2 3 4 5 6 7 ... 492 493 494 495 496 497 498 499\n", + " * chain (chain) int64 64B 0 1 2 3 4 5 6 7\n", + " * draw (draw) int64 4kB 0 1 2 3 4 5 6 7 ... 493 494 495 496 497 498 499\n", "Data variables:\n", - " y_sigma (chain, draw) float64 0.9098 0.9531 0.9082 ... 0.878 0.9928\n", - " Intercept (chain, draw) float64 -0.02762 0.07108 ... 0.01903 0.0508\n", - " x (chain, draw) float64 0.3369 0.395 0.3184 ... 0.2896 0.4378\n", + " Intercept (chain, draw) float64 32kB 0.04421 0.1077 ... 0.0259 0.06753\n", + " x (chain, draw) float64 32kB 0.1353 0.232 0.5141 ... 0.2195 0.5014\n", + " y_sigma (chain, draw) float64 32kB 0.9443 0.9102 0.922 ... 0.9597 0.9249\n", "Attributes:\n", - " created_at: 2024-03-01T14:56:58.167509\n", - " arviz_version: 0.17.0\n", + " created_at: 2024-04-13T05:34:49.761913+00:00\n", + " arviz_version: 0.18.0\n", " modeling_interface: bambi\n", - " modeling_interface_version: 0.13.1.dev16+g9a1387a7.d20240204
<xarray.Dataset>\n", + "<xarray.Dataset> Size: 200kB\n", "Dimensions: (chain: 8, draw: 500)\n", "Coordinates:\n", - " * chain (chain) int64 0 1 2 3 4 5 6 7\n", - " * draw (draw) int64 0 1 2 3 4 5 6 ... 493 494 495 496 497 498 499\n", + " * chain (chain) int64 64B 0 1 2 3 4 5 6 7\n", + " * draw (draw) int64 4kB 0 1 2 3 4 5 6 ... 494 495 496 497 498 499\n", "Data variables:\n", - " lp (chain, draw) float64 -139.5 -139.5 ... -139.9 -139.9\n", - " step_size (chain, draw) float64 0.7258 0.7258 ... 0.7077 0.7077\n", - " diverging (chain, draw) bool False False False ... False False False\n", - " energy (chain, draw) float64 141.2 139.9 139.7 ... 140.1 140.3\n", - " tree_depth (chain, draw) int64 2 3 3 3 3 2 3 3 2 ... 2 3 3 3 2 2 3 3 3\n", - " n_steps (chain, draw) int64 3 7 7 7 7 3 7 7 3 ... 3 7 7 7 3 3 7 7 7\n", - " acceptance_rate (chain, draw) float64 0.9614 0.9746 ... 0.9652 0.9926\n", + " acceptance_rate (chain, draw) float64 32kB 0.8137 1.0 1.0 ... 0.9094 0.9834\n", + " diverging (chain, draw) bool 4kB False False False ... False False\n", + " energy (chain, draw) float64 32kB 142.0 142.5 ... 143.0 141.5\n", + " lp (chain, draw) float64 32kB -141.8 -140.8 ... -140.3 -140.3\n", + " n_steps (chain, draw) int64 32kB 3 3 7 7 7 3 3 7 ... 7 3 7 5 7 3 7\n", + " step_size (chain, draw) float64 32kB 0.7326 0.7326 ... 0.7643 0.7643\n", + " tree_depth (chain, draw) int64 32kB 2 2 3 3 3 2 2 3 ... 3 2 3 3 3 2 3\n", "Attributes:\n", - " created_at: 2024-03-01T14:56:58.169388\n", - " arviz_version: 0.17.0\n", + " created_at: 2024-04-13T05:34:49.763427+00:00\n", + " arviz_version: 0.18.0\n", " modeling_interface: bambi\n", - " modeling_interface_version: 0.13.1.dev16+g9a1387a7.d20240204
\n", + "\n" + ], + "text/plain": [ + "\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, { "data": { "text/html": [ @@ -1568,8 +1620,8 @@ "
<xarray.Dataset>\n", + "<xarray.Dataset> Size: 26kB\n", "Dimensions: (chain: 4, draw: 250)\n", "Coordinates:\n", - " * chain (chain) int64 0 1 2 3\n", - " * draw (draw) int64 0 1 2 3 4 5 6 7 ... 242 243 244 245 246 247 248 249\n", + " * chain (chain) int64 32B 0 1 2 3\n", + " * draw (draw) int64 2kB 0 1 2 3 4 5 6 7 ... 243 244 245 246 247 248 249\n", "Data variables:\n", - " y_sigma (chain, draw) float64 1.078 1.05 0.8647 ... 0.856 0.9391 0.9165\n", - " Intercept (chain, draw) float64 -0.1116 -0.1474 ... -0.04961 0.0266\n", - " x (chain, draw) float64 0.4042 0.3106 0.4226 ... 0.2611 0.3592\n", + " Intercept (chain, draw) float64 8kB 0.112 -0.08016 ... -0.04784 -0.04427\n", + " x (chain, draw) float64 8kB 0.4311 0.3077 0.2568 ... 0.557 0.4814\n", + " y_sigma (chain, draw) float64 8kB 0.9461 0.9216 0.9021 ... 0.9574 0.9414\n", "Attributes:\n", - " created_at: 2024-03-01T14:57:03.782531\n", - " arviz_version: 0.17.0\n", + " created_at: 2024-04-13T05:36:20.439151+00:00\n", + " arviz_version: 0.18.0\n", " modeling_interface: bambi\n", - " modeling_interface_version: 0.13.1.dev16+g9a1387a7.d20240204
<xarray.Dataset>\n", + "<xarray.Dataset> Size: 51kB\n", "Dimensions: (chain: 4, draw: 250)\n", "Coordinates:\n", - " * chain (chain) int64 0 1 2 3\n", - " * draw (draw) int64 0 1 2 3 4 5 6 ... 243 244 245 246 247 248 249\n", + " * chain (chain) int64 32B 0 1 2 3\n", + " * draw (draw) int64 2kB 0 1 2 3 4 5 6 ... 244 245 246 247 248 249\n", "Data variables:\n", - " lp (chain, draw) float64 -142.2 -141.9 ... -139.9 -139.3\n", - " step_size (chain, draw) float64 0.9072 0.9072 ... 0.7606 0.7606\n", - " diverging (chain, draw) bool False False False ... False False False\n", - " energy (chain, draw) float64 144.6 143.1 142.2 ... 141.1 140.1\n", - " tree_depth (chain, draw) int64 3 3 2 3 2 1 2 2 2 ... 3 3 2 2 3 3 2 3 2\n", - " n_steps (chain, draw) int64 7 7 3 7 3 1 3 3 3 ... 7 7 3 3 7 7 3 7 3\n", - " acceptance_rate (chain, draw) float64 1.0 0.9854 0.9968 ... 0.9882 0.9931\n", + " acceptance_rate (chain, draw) float64 8kB 0.8489 0.9674 ... 0.983 1.0\n", + " diverging (chain, draw) bool 1kB False False False ... False False\n", + " energy (chain, draw) float64 8kB 141.2 140.7 140.5 ... 141.9 141.4\n", + " lp (chain, draw) float64 8kB -139.9 -140.0 ... -141.6 -140.3\n", + " n_steps (chain, draw) int64 8kB 3 7 7 3 3 3 7 3 ... 3 3 3 3 3 3 3 3\n", + " step_size (chain, draw) float64 8kB 0.8923 0.8923 ... 0.9726 0.9726\n", + " tree_depth (chain, draw) int64 8kB 2 3 3 2 2 2 3 2 ... 2 2 2 2 2 2 2 2\n", "Attributes:\n", - " created_at: 2024-03-01T14:57:03.784254\n", - " arviz_version: 0.17.0\n", + " created_at: 2024-04-13T05:36:20.441267+00:00\n", + " arviz_version: 0.18.0\n", " modeling_interface: bambi\n", - " modeling_interface_version: 0.13.1.dev16+g9a1387a7.d20240204
\n", + "\n" + ], + "text/plain": [ + "\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, { "data": { "text/html": [ @@ -3140,8 +3230,8 @@ "
<xarray.Dataset>\n", + "<xarray.Dataset> Size: 200kB\n", "Dimensions: (chain: 8, draw: 1000)\n", "Coordinates:\n", - " * chain (chain) int64 0 1 2 3 4 5 6 7\n", - " * draw (draw) int64 0 1 2 3 4 5 6 7 ... 992 993 994 995 996 997 998 999\n", + " * chain (chain) int64 64B 0 1 2 3 4 5 6 7\n", + " * draw (draw) int64 8kB 0 1 2 3 4 5 6 7 ... 993 994 995 996 997 998 999\n", "Data variables:\n", - " y_sigma (chain, draw) float64 0.9946 0.8708 0.8651 ... 0.9908 0.9958\n", - " Intercept (chain, draw) float64 -0.09685 -0.01575 0.0419 ... 0.1091 0.1152\n", - " x (chain, draw) float64 0.4584 0.399 0.4485 ... 0.5167 0.4703\n", + " Intercept (chain, draw) float64 64kB -0.1597 0.2011 ... 0.1525 -0.171\n", + " x (chain, draw) float64 64kB 0.2515 0.4686 0.4884 ... 0.5085 0.4896\n", + " y_sigma (chain, draw) float64 64kB 0.9735 0.8969 0.8002 ... 0.9422 1.045\n", "Attributes:\n", - " created_at: 2024-03-01T15:57:23.746257\n", - " arviz_version: 0.17.0\n", + " created_at: 2024-04-13T05:36:30.303342+00:00\n", + " arviz_version: 0.18.0\n", " modeling_interface: bambi\n", - " modeling_interface_version: 0.13.1.dev16+g9a1387a7.d20240204
<xarray.Dataset>\n", + "<xarray.Dataset> Size: 312kB\n", "Dimensions: (chain: 8, draw: 1000)\n", "Coordinates:\n", - " * chain (chain) int64 0 1 2 3 4 5 6 7\n", - " * draw (draw) int64 0 1 2 3 4 5 6 ... 993 994 995 996 997 998 999\n", + " * chain (chain) int64 64B 0 1 2 3 4 5 6 7\n", + " * draw (draw) int64 8kB 0 1 2 3 4 5 6 ... 994 995 996 997 998 999\n", "Data variables:\n", - " accept_ratio (chain, draw) float64 1.0 0.9889 0.9769 ... 1.0 0.9975 1.0\n", - " diverging (chain, draw) bool False False False ... False False False\n", - " is_accepted (chain, draw) bool True True True True ... True True True\n", - " n_steps (chain, draw) int32 7 3 7 7 3 7 3 7 7 ... 3 3 7 3 7 1 1 3 7\n", - " step_size (chain, draw) float64 0.5332 0.5332 0.5332 ... nan nan nan\n", - " target_log_prob (chain, draw) float64 -141.0 -139.9 ... -140.9 -140.5\n", - " tune (chain, draw) float64 0.0 0.0 0.0 0.0 ... nan nan nan nan\n", + " accept_ratio (chain, draw) float64 64kB 0.8971 0.9944 ... 0.9174 0.8133\n", + " diverging (chain, draw) bool 8kB False False False ... False False\n", + " is_accepted (chain, draw) bool 8kB True True True ... True True True\n", + " n_steps (chain, draw) int32 32kB 7 7 7 1 7 7 7 3 ... 3 7 7 7 3 7 7\n", + " step_size (chain, draw) float64 64kB 0.534 0.534 0.534 ... nan nan\n", + " target_log_prob (chain, draw) float64 64kB -141.5 -141.7 ... -141.0 -143.2\n", + " tune (chain, draw) float64 64kB 0.0 0.0 0.0 0.0 ... nan nan nan\n", "Attributes:\n", - " created_at: 2024-03-01T15:57:23.747950\n", - " arviz_version: 0.17.0\n", + " created_at: 2024-04-13T05:36:30.304788+00:00\n", + " arviz_version: 0.18.0\n", " modeling_interface: bambi\n", - " modeling_interface_version: 0.13.1.dev16+g9a1387a7.d20240204
\n", + "\n" + ], + "text/plain": [ + "\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, { "data": { "text/html": [ @@ -4408,8 +4536,8 @@ "
<xarray.Dataset>\n", + "<xarray.Dataset> Size: 200kB\n", "Dimensions: (chain: 8, draw: 1000)\n", "Coordinates:\n", - " * chain (chain) int64 0 1 2 3 4 5 6 7\n", - " * draw (draw) int64 0 1 2 3 4 5 6 7 ... 992 993 994 995 996 997 998 999\n", + " * chain (chain) int64 64B 0 1 2 3 4 5 6 7\n", + " * draw (draw) int64 8kB 0 1 2 3 4 5 6 7 ... 993 994 995 996 997 998 999\n", "Data variables:\n", - " Intercept (chain, draw) float64 -0.02485 0.1376 -0.00766 ... 0.01202 0.0375\n", - " x (chain, draw) float64 0.4336 0.4907 0.4996 ... 0.4032 0.3964\n", - " y_sigma (chain, draw) float64 0.9225 1.015 0.9409 ... 0.8574 0.9083 0.822\n", + " Intercept (chain, draw) float64 64kB 0.0004764 0.02933 ... 0.1217 0.1668\n", + " x (chain, draw) float64 64kB 0.3836 0.6556 0.2326 ... 0.48 0.5808\n", + " y_sigma (chain, draw) float64 64kB 0.8821 0.9604 0.9652 ... 0.9063 0.9184\n", "Attributes:\n", - " created_at: 2024-03-01T14:57:07.292211\n", - " arviz_version: 0.17.0\n", + " created_at: 2024-04-13T05:36:33.599519+00:00\n", + " arviz_version: 0.18.0\n", " inference_library: numpyro\n", - " inference_library_version: 0.13.2\n", + " inference_library_version: 0.14.0\n", " modeling_interface: bambi\n", - " modeling_interface_version: 0.13.1.dev16+g9a1387a7.d20240204
<xarray.Dataset>\n", + "<xarray.Dataset> Size: 400kB\n", "Dimensions: (chain: 8, draw: 1000)\n", "Coordinates:\n", - " * chain (chain) int64 0 1 2 3 4 5 6 7\n", - " * draw (draw) int64 0 1 2 3 4 5 6 ... 993 994 995 996 997 998 999\n", + " * chain (chain) int64 64B 0 1 2 3 4 5 6 7\n", + " * draw (draw) int64 8kB 0 1 2 3 4 5 6 ... 994 995 996 997 998 999\n", "Data variables:\n", - " acceptance_rate (chain, draw) float64 0.9973 0.6392 0.987 ... 0.9744 0.8087\n", - " step_size (chain, draw) float64 0.7525 0.7525 ... 0.8295 0.8295\n", - " diverging (chain, draw) bool False False False ... False False False\n", - " energy (chain, draw) float64 140.6 143.8 141.9 ... 140.8 141.4\n", - " n_steps (chain, draw) int64 3 3 3 3 1 1 3 7 7 ... 7 7 3 7 7 7 15 3\n", - " tree_depth (chain, draw) int64 2 2 2 2 1 1 2 3 3 ... 2 3 3 2 3 3 3 4 2\n", - " lp (chain, draw) float64 139.7 141.1 140.3 ... 139.4 141.0\n", + " acceptance_rate (chain, draw) float64 64kB 0.9366 0.3542 ... 0.9903 0.8838\n", + " diverging (chain, draw) bool 8kB False False False ... False False\n", + " energy (chain, draw) float64 64kB 140.3 145.4 ... 141.0 142.6\n", + " lp (chain, draw) float64 64kB 139.6 143.3 ... 140.5 142.5\n", + " n_steps (chain, draw) int64 64kB 3 3 7 3 7 1 3 3 ... 11 7 3 3 3 3 3\n", + " step_size (chain, draw) float64 64kB 0.8891 0.8891 ... 0.7595 0.7595\n", + " tree_depth (chain, draw) int64 64kB 2 2 3 2 3 1 2 2 ... 4 3 2 2 2 2 2\n", "Attributes:\n", - " created_at: 2024-03-01T14:57:07.316723\n", - " arviz_version: 0.17.0\n", + " created_at: 2024-04-13T05:36:33.623197+00:00\n", + " arviz_version: 0.18.0\n", " inference_library: numpyro\n", - " inference_library_version: 0.13.2\n", + " inference_library_version: 0.14.0\n", " modeling_interface: bambi\n", - " modeling_interface_version: 0.13.1.dev16+g9a1387a7.d20240204
\n", + "\n" + ], + "text/plain": [ + "\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, { "data": { "text/html": [ @@ -5708,8 +5881,8 @@ "
<xarray.Dataset>\n", + "<xarray.Dataset> Size: 244kB\n", "Dimensions: (chain: 20, draw: 500)\n", "Coordinates:\n", - " * chain (chain) int64 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19\n", - " * draw (draw) int64 0 1 2 3 4 5 6 7 ... 492 493 494 495 496 497 498 499\n", + " * chain (chain) int64 160B 0 1 2 3 4 5 6 7 8 ... 12 13 14 15 16 17 18 19\n", + " * draw (draw) int64 4kB 0 1 2 3 4 5 6 7 ... 493 494 495 496 497 498 499\n", "Data variables:\n", - " y_sigma (chain, draw) float64 0.8082 1.024 1.024 ... 0.971 0.971 0.971\n", - " Intercept (chain, draw) float64 0.09035 0.06867 0.06867 ... -0.1322 -0.1322\n", - " x (chain, draw) float64 0.4452 0.503 0.503 ... 0.3238 0.3238 0.3238\n", + " Intercept (chain, draw) float64 80kB -0.07404 -0.07404 ... -0.1455 0.09545\n", + " x (chain, draw) float64 80kB 0.4401 0.4401 0.3533 ... 0.6115 0.3824\n", + " y_sigma (chain, draw) float64 80kB 0.9181 0.9181 0.9732 ... 1.049 0.9643\n", "Attributes:\n", - " created_at: 2024-03-01T14:57:59.802971\n", - " arviz_version: 0.17.0\n", + " created_at: 2024-04-13T05:37:29.798250+00:00\n", + " arviz_version: 0.18.0\n", " modeling_interface: bambi\n", - " modeling_interface_version: 0.13.1.dev16+g9a1387a7.d20240204