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

traceplot using anywidget #36

Open
3 tasks done
amaloney opened this issue Jun 7, 2024 · 16 comments
Open
3 tasks done

traceplot using anywidget #36

amaloney opened this issue Jun 7, 2024 · 16 comments
Assignees
Labels
enhancement New feature or request

Comments

@amaloney
Copy link
Collaborator

amaloney commented Jun 7, 2024

  • Get anywidget to output anything
  • Parse the posterior of an InferenceData object
  • Use bokeh.js or plotly.js to create a figure (using observablehq/plot)
@amaloney amaloney added the enhancement New feature or request label Jun 7, 2024
@amaloney amaloney self-assigned this Jun 7, 2024
@amaloney
Copy link
Collaborator Author

Development has started. I was able to get anywidget to render the data_vars of the centered 8 InferenceData.

@amaloney
Copy link
Collaborator Author

while not a forestplot, I have an @observablehq/plot being rendered by JavaScript using anywidget to build the plot, which is of the penguins data

image

Next step is to manipulate the posterior data in JS to get the required data for a forestplot

@OriolAbril
Copy link
Member

Do you want the data processing to be done in javascript? Or precomputed in python? I looked a bit at observablehq website and it wasn't clear to me how data processing happens

@amaloney
Copy link
Collaborator Author

I would like to try having data computations done in the browser, if they are not resource intensive. This is why the arviz.js repo exists; to handle computations that the browser can do easily, and update the plots accordingly.

@amaloney
Copy link
Collaborator Author

The dropdown menus didn't show when clicked (for what ever reason) but the code now parses through the posterior object to populate one dropdown with data_vars and the other dropdown with any coords associated with the selected data_var.

2024-09-12_17-22-50.webm

@amaloney
Copy link
Collaborator Author

Parsing through the data is going to be a challenge, and we may want to use something like DuckDB for it...maybe.

@yilinxia what are your opinions about using DuckDB vs not?

@amaloney
Copy link
Collaborator Author

After looking at DuckDB, I do not think we should use it as a tool since we would need to use the wasm version of it, and that seem unnecessarily heavy atm. I will continue to work on parsing the InferenceData object so we can visualize it.

@yilinxia
Copy link
Member

From my experience with DuckDB, it is pretty powerful and VERY fast.
But I am not fully sure how it performs in terms of the dataset we are working on.

Yeah, WASM would be a great use case for DuckDB and we possibly will use it if we plan to make the computation happens in the browser.

@amaloney
Copy link
Collaborator Author

Not a forest plot, but it is parsing the posterior data object and I'm able to get observable to plot a trace plot. Next step is to add interactivity with the menus so that the plot updates on changes.

image

@amaloney
Copy link
Collaborator Author

hooking up interactivity with the menus was a straight forward callback. Note that this will fail when there are no coordinates associated with a variable, so other checks need to be made for non-hierarchical values.

Screencast.from.2024-09-13.22-00-45.webm

@amaloney
Copy link
Collaborator Author

I've diverged from creating a forestplot (atm) to look at interactivity etc for traceplots. Below shows the dropdowns correctly updating the figure with tooltips as you move the mouse. Next thing I'll try is getting an interactive legend.

Screencast.from.2024-09-15.16-16-50.webm

@amaloney
Copy link
Collaborator Author

Step closer, with chains being muted. Still need to figure out how to prevent the tips from overlapping.

Screencast.from.2024-09-15.22-21-22.webm

@amaloney
Copy link
Collaborator Author

amaloney commented Oct 9, 2024

definitely not a forestplot yet, but the posterior DataTree object is fully parsed, passed to JavaScript and menus update the figure with callbacks populating each dropdown programmatically. This is using arvizjs now, so next step is to make a KDE for this @aloctavodia @yilinxia

tagging @OriolAbril and @zaxtax if you're interested

2024-10-09.00-18-55.webm

@amaloney amaloney changed the title forestplot using anywidget traceplot using anywidget Oct 10, 2024
@amaloney
Copy link
Collaborator Author

dropdowns are not showing, but I've decided to switch this from a forestplot to the traceplot that is functioning well. Now to apply some styling

2024-10-09_19-16-09.webm

@amaloney
Copy link
Collaborator Author

A few hoops to go through due to the package not being completely built from the branch, but it straight up works in colab

2024-10-09_19-55-57.webm

@amaloney
Copy link
Collaborator Author

Previous iterations assumed single hierarchical variables, eg a(b) and not a(b, c). This version handles that, and does not assume a set number of hierarchical variables. This can be seen when we change data from rugby to rubgy_field.

2024-10-23-17-19-30_1.webm

There are a few more items to deal with, but I'm inclined to have this reviewed in a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants