-
-
Notifications
You must be signed in to change notification settings - Fork 393
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
Added example to plot_hdi using Inference data #1615
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1615 +/- ##
=======================================
Coverage 90.91% 90.91%
=======================================
Files 108 108
Lines 11671 11671
=======================================
Hits 10611 10611
Misses 1060 1060
Continue to review full report at Codecov.
|
arviz/plots/hdiplot.py
Outdated
>>> data = az.load_arviz_data('radon') | ||
>>> x_data = np.array(data.posterior_predictive.obs_id) | ||
>>> y_data = np.array(data.posterior_predictive.y) | ||
>>> az.plot_hdi(x_data, y_data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if you have looked at how the plot looks like, but obs_id
are integer indexes that don't really have any meaning, they should not be used as x values. They are also not continuous, so plotting a continuous hdi band over all observations is not a good idea either.
I think this should be done with the regression1d example better, but it looks like the InferenceData does not have the x values used as predictiors. Going down this path would require solving #1291 and extending the code to get the x data into the inferencedata, which will probably take some time.
As a more immediate solution, I would use simulated data (maybe even the same as above) to create a new inferencedata instead of loading a preexisting one and then use this one to plot the hdi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that makes sense, I too was confused about this bit. I was also thinking of creating a new Inference Object and using that to plot the HDI but as the issue suggested to use pre-computed data so went on with that approach to see if it was possible. So as of now, it is not possible as there are no x values in the posterior predictive or the posterior. Will make the necessary changes. Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor note, the x values would be in the constant_data
group
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!, could you check @OriolAbril? Thanks
bcf1b54
to
de1dd90
Compare
arviz/plots/hdiplot.py
Outdated
>>> X = {"x":X} | ||
>>> Y = {"y": Y} | ||
>>> dataset = az.from_dict(posterior=Y, constant_data = X) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
>>> X = {"x":X} | |
>>> Y = {"y": Y} | |
>>> dataset = az.from_dict(posterior=Y, constant_data = X) | |
>>> idata = az.from_dict(posterior_predictive={"y" : Y}, constant_data = {"x" : X}) |
I'd recommend using this names instead. y
is generally used for observed data, and its values will generally be stored in the posterior predictive group instead of the posterior, and I would avoid dataset
as a name because the object it represents is an InferenceData
as opposed to an xr.Dataset
which could be confusing, due to this double meaning of dataset.
de1dd90
to
740ce3f
Compare
* Added example to plot_hdi using Inference data * Minor Changes * linted code * Added x values to Inference Data Object * Added example to plot_hdi using Inference data * Minor Changes * linted code * Minor changes * Updated CHANGELOG
Description
To fix #1479
Checklist