Skip to content
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

Adding MCSE Plot #79

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Adding MCSE Plot #79

wants to merge 6 commits into from

Conversation

imperorrp
Copy link
Collaborator

@imperorrp imperorrp commented Aug 5, 2024

First commit for MCSE plot. A lot of ESS plot conventions are followed, including the extra methods (mean and sd) and scatter_xy visual element portions developed in it.

The computing of quantiles for plotting the errorbars as desired requires subsetting the distribution so the subsets can be flattened and then the arviz-stats quantile function called- the xarray_sel_iter function from arviz_base was imported and attempted to be used for this. I then tried to concatenate the computed values to the mcse_dataset along the plot_axis dim as coordinate 'z'. There are some issues with achieving this though since the xr.concat() and xr.merge() are not in-place functions so the logic/algorithm for extending mcse_dataset like this might need more thought. There might be a simpler way to do this that I haven't thought of though. This bit is marked as WIP in the code. If we pick the alternative (below) approach it could be removed altogether.

Since pc.map() automatically subsets DataArray/Dataset type objects passed to it, moving the computation to the new error_bar visual element function makes it a lot more simple so this is the current implementation I've kept in this commit. This requires calling arviz-stats and doing some computation in the visual element function which none of the other visual element functions do, but it works already. If any other plots with different logic also require usage of this visual element function then modifications might be needed.

Also added the backend function errorbar for backend=None and backend=Matplotlib so far. The Bokeh and the new Plotly backend's implementations are left.

The current visual outputs of the plot are like this:

image

image

image

image

image


📚 Documentation preview 📚: https://arviz-plots--79.org.readthedocs.build/en/79/

@codecov-commenter
Copy link

codecov-commenter commented Aug 5, 2024

Codecov Report

Attention: Patch coverage is 73.75000% with 63 lines in your changes missing coverage. Please review.

Project coverage is 83.81%. Comparing base (f4a39af) to head (cb32a45).

Files with missing lines Patch % Lines
src/arviz_plots/backend/bokeh/__init__.py 5.26% 18 Missing ⚠️
src/arviz_plots/backend/none/__init__.py 6.66% 14 Missing ⚠️
src/arviz_plots/backend/matplotlib/__init__.py 7.14% 13 Missing ⚠️
src/arviz_plots/plots/mcseplot.py 92.48% 13 Missing ⚠️
src/arviz_plots/visuals/__init__.py 72.22% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #79      +/-   ##
==========================================
- Coverage   84.80%   83.81%   -1.00%     
==========================================
  Files          21       22       +1     
  Lines        2336     2576     +240     
==========================================
+ Hits         1981     2159     +178     
- Misses        355      417      +62     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


# print(f"\n final z_mcse_dataset = {z_mcse_dataset}")

# for now the quantile_values can be computed in the visual element function itself
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you already have xdata_dataset, also mcse_y_dataset (which now should be the errorbars, not the y position). I think quantiles_dataset = distribution.quantile(probs, dim=mcse_dims) will mostly give you what you want, the only problem is it will have a quantile dimension instead of an mcse_dim one, you can rename and reindex it or use quantile as dimension name for the other objects.

afer that you should be able to concat them into a new object with plot_axis having x (xdata_dataset), y (quantiles_dataset) and error (mcse_y_dataset) so the visual function can process that and still accept x, y in case we want aesthetics mapped to them

@imperorrp
Copy link
Collaborator Author

Added the Bokeh backend function for errorbars. The dash function used in the legacy MCSE plot is deprecated now so scatter was used instead, and the multi_line function was retained:

image

@imperorrp
Copy link
Collaborator Author

Rebased the PR

@imperorrp imperorrp mentioned this pull request Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants