-
-
Notifications
You must be signed in to change notification settings - Fork 411
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
Included estimate of probability within ROPE #1570
Conversation
@OriolAbril could you take a look and give your feedback. Thanks |
Will take a look whenever posssible, before that though, as the changes affect plotting, can you add some screenshots of the resulting plots? |
@OriolAbril For: |
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.
Thanks for the pr :), I added a couple of cosmetic changes
less_than_left_probability = (values < vals[0]).mean() | ||
less_than_right_probability = (values <= vals[1]).mean() | ||
probability_within_rope = less_than_right_probability - less_than_left_probability |
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.
less_than_left_probability = (values < vals[0]).mean() | |
less_than_right_probability = (values <= vals[1]).mean() | |
probability_within_rope = less_than_right_probability - less_than_left_probability | |
probability_within_rope = ((values > vals[0]) & (values <= vals[1])).mean() |
I think this will perform better in terms of memory usage, values are not generally too large arrays but I think it's better to be cautious. It should return the same value.
probability_within_rope = less_than_right_probability - less_than_left_probability | ||
ax.text( | ||
x=(vals[0]+vals[1])/2, | ||
y=[max_data * 0.5], |
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.
Can you try other values and see if you can get the rope text to be between the ref_val and hdi text?
@OriolAbril is this ok? |
Looks great now, thanks! |
Then I will commit the changes and also add it to the CHANGELOG.md |
If you are up for it I think ideally both plots would look the same, green for rope and orange for ref val. If you decide to work on this make sure to fetch the lastest changes to main branch and rebase |
Yes, I will work on this. Thanks @OriolAbril |
It's the code style check, in this case black; here is a direct link to the message https://dev.azure.com/ArviZ/ArviZ/_build/results?buildId=3989&view=logs&j=af9a1d3a-ff8f-5483-6823-86518c773a9b&t=6a1cfc46-f4a4-5e3c-e2fb-18ea29f733bf&l=15, you can also get there by clicking details on the job and then the link to Azure. |
367fdd1
to
363ae53
Compare
@OriolAbril does this work? |
Looks good, but it would be great if it was possible to hardcode the colors (in matplotlib the colors used are C0, C1... which are defined by the current style, you can try out different styles and see how the colors change). Two options to do this come to mind, the first is to add The 2nd is to use our helper function
|
@OriolAbril I am familiar with the 2nd method, I have seen an issue regarding that |
The general approach in plotting functions is to have the base function (in arviz/plots) do some data wrangling and (sometimes also define some defaults as kwarg dictionaries) and then pass these dictionaries to the selected backend function which is the one that does the plotting. See in pairplot for example: the defaults are taken from this matplotlib defaults in order to work with mpl styles out of the box, but it is also possible to use kwarg dicts for customization that goes further or diverges from the style. The 2 approaches I described above are not exclusive, vectorized_to_hex would also be used in the kwargs option, the difference is that the color would not be so hardcoded. I don't remember seeing anyone complaining about the colors in plot_posterior, so maybe the 2nd option is enough to handle this as it already allows some level of customization |
@OriolAbril so I am facing this problem: In the case of bokeh plot we have different arguments for Similarly for the case of matplotlib in that case though we have a common argument for Similarly for |
Given that nobody has ever asked to customize the rope or ref val, I think allowing to change the color only should be enough. I am not sure the feature is worth all the effort to add kwargs or split them. Having to use styles to change this seems fine to me even if it is a bit cryptic, maybe we could also add a |
So I will just modify the code to incorporate only the color arguments(for both |
363ae53
to
16ca922
Compare
@OriolAbril could you look at the changes. Thanks |
Codecov Report
@@ Coverage Diff @@
## main #1570 +/- ##
=======================================
Coverage 89.99% 89.99%
=======================================
Files 107 107
Lines 11532 11535 +3
=======================================
+ Hits 10378 10381 +3
Misses 1154 1154
Continue to review full report at Codecov.
|
@OriolAbril made the changes, can you review? Thanks |
Thanks @Rishabh261998! |
* Included estimate of probability within ROPE * Positioned ROPE text and added to CHANGELOG * Changed color scheme in plot_posterior in bokeh * Changed size of rope text in posteriorplot bokeh * Added rope_color and ref_val_color arguments to plot_posterior * Minor Changes * Some minor changes
Description
Included the estimate of probability within ROPE. To fix #1567
Checklist