-
-
Notifications
You must be signed in to change notification settings - Fork 412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add helper function to easily stack chain
and draws
dimensions
#1469
Comments
Is there a reason we can not add this when we create InferenceData? Would anything change or break? I think it would only add one more dimension, but everything else is same? |
I don't think anything would break, as you can still access |
Proposal for this, a def get_dataset(idata, group="posterior", combined=False, var_names=None, filter_vars=None):
"""Extracts an inference data group or subset of it as xarray dataset
Parameters
----------
idata : InferenceData
InferenceData from which to extract the data.
<not sure if it should be idata or anything that can be converted to idata>
group : str, default "posterior"
combined : bool, default False?
var_names : str or list of str, optional
Like with plotting, sometimes it's easier to subset saying what to exclude instead of what to include
filter_vars : like with plotting
Returns
-------
xarray.Dataset (or xarray.DataArray?)
I am not sure whether we should return a dataarray iff `var_names` is a string
and a dataset otherwise or always a dataset.
""" I believe this will handle most practical cases and be quite flexible while still being very little code as everything is reused from other functions/externalized. |
Hi! I recently submitted a PR for updating GLM poisson regression to best practices, and on executing cell 18 in that notebook
I get this RuntimeWarning:
Here, @OriolAbril suggested that this might be relevant to the discussion here. |
yeah, here we basically want to exponentiate all varibles except mu because |
Stacking chains and draws is often useful when one doesn't care about which chain a draw is coming from. This is currently possible by doing
idata.posterior.stack(sample=("chain", "draw"))
, but very few people seem to know that.Adding a helper function to easily stack the
chain
anddraws
dimensions into asample
dimension would go a long way towards making users' life easier, as well as making better use ofxarray
's capabilities. Feel free to comment if you want to take on this issue 🖖The text was updated successfully, but these errors were encountered: