Skip to content

Use coords / xarray magic in dependent density regression #146

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

Merged
merged 2 commits into from
Jul 3, 2021

Conversation

MarcoGorelli
Copy link
Contributor

@MarcoGorelli MarcoGorelli commented Apr 24, 2021

xref #14

Is there a way to avoid having to do

beta = pm.Normal("beta", 0.0, 5.0, shape=(1, K))

?
If there was shape=K, I could put dims='K', but then

pm.math.dot(x, beta)

wouldn't work.

Any hints?

EDIT (Oriol): Addresses #99

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@@ -2,16 +2,7 @@
"cells": [
Copy link
Member

Choose a reason for hiding this comment

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

You can use "one": [1] in coords dict, or any other name/coord value you may prefer, it just has to be there and have length one to act as the 1 in shape.


Reply via ReviewNB

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so simple, thanks!

@MarcoGorelli MarcoGorelli changed the title Use coords / arviz magic in dependent density regression Use coords / xarray magic in dependent density regression Apr 24, 2021
@@ -2,16 +2,7 @@
"cells": [
Copy link
Contributor Author

Choose a reason for hiding this comment

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

so much more readable with xarray magic...


Reply via ReviewNB

Copy link
Member

Choose a reason for hiding this comment

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

:)

Updating the examples is being an amazing resource for me to both see the potential of xarray as well as where is more help and work needed. I don't need convincing on xarray usage, but there are still things where it surprises me.

As a side not, I think somehting like max_mixture_weights["K"].values will be equivalent tomax_mixture_weights.coords.to_index() . The distinction between coord and variable is still something I don't grok yet, especially because of non-indexing coords, but it is cool to be able to treat coords as variables in many cases

@fonnesbeck fonnesbeck merged commit 0bf5448 into pymc-devs:main Jul 3, 2021
@fonnesbeck
Copy link
Member

Thanks, @MarcoGorelli

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