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

update GLM out of sample prediction notebook to v4 #370

Merged
merged 32 commits into from
Jun 7, 2022

Conversation

drbenvincent
Copy link
Contributor

ref #85

  • Updated to v4
  • Added various markup elements
  • Removed mention of PyMC3 and also of dead notebooks
  • Minor refactoring of some code just to keep the global scope clean and to increase readability a little
  • switched to rng = np.random.default_rng as per the style guide. Along the way the random seed for sampling got removed. Can always put that back if need be.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@review-notebook-app
Copy link

review-notebook-app bot commented Jun 5, 2022

View / edit / reply to this conversation on ReviewNB

cluhmann commented on 2022-06-05T15:59:27Z
----------------------------------------------------------------

Per the Jupyter style guide, the preamble should be like this (omitting the figure format line):

RANDOM_SEED = 8927
rng = np.random.default_rng(RANDOM_SEED)
az.style.use("arviz-darkgrid")

drbenvincent commented on 2022-06-05T16:54:13Z
----------------------------------------------------------------

Done, in upcoming commit

@review-notebook-app
Copy link

review-notebook-app bot commented Jun 5, 2022

View / edit / reply to this conversation on ReviewNB

cluhmann commented on 2022-06-05T15:59:28Z
----------------------------------------------------------------

Do we want to keep this? It's quite old and the use of pm.MutableData below renders this somewhat obsolete.


drbenvincent commented on 2022-06-05T16:54:25Z
----------------------------------------------------------------

removing this in upcoming commit

@review-notebook-app
Copy link

review-notebook-app bot commented Jun 5, 2022

View / edit / reply to this conversation on ReviewNB

cluhmann commented on 2022-06-05T15:59:30Z
----------------------------------------------------------------

I think it's convention to index into InferenceData objects like this? I could be wrong and it probably doesn't matter too much.

idata.posterior_predictive['obs']mean(dim=["chain", "draw"])

drbenvincent commented on 2022-06-05T16:54:32Z
----------------------------------------------------------------

Agreed

@review-notebook-app
Copy link

review-notebook-app bot commented Jun 5, 2022

View / edit / reply to this conversation on ReviewNB

cluhmann commented on 2022-06-05T15:59:30Z
----------------------------------------------------------------

Just a naming issue, but should the variables x1 and x2 be b1 and b1 or am I confused?


drbenvincent commented on 2022-06-05T16:56:55Z
----------------------------------------------------------------

Doesn't need to be because I used labels for the coefficient names. But here I agree, so I've changed them to b0, b1, b2, b1:b2

cluhmann commented on 2022-06-05T19:29:57Z
----------------------------------------------------------------

I guess I meant that x1 here (i.e., idata.posterior.b.sel(coeffs="b1").mean().data) is the mean posterior of a coefficient that is labeled "b1", which is then multiplied by the "x1" taken from the grid (i.e., x1_grid). So I guess I assumed that idata.posterior.b.sel(coeffs="b1").mean().data would be stored in a variable named b1 rather than x1.

Also, as in the comment resolved above, I tend to do: idata.posterior["b"] rather than idata.posterior.b.

@review-notebook-app
Copy link

review-notebook-app bot commented Jun 5, 2022

View / edit / reply to this conversation on ReviewNB

cluhmann commented on 2022-06-05T15:59:31Z
----------------------------------------------------------------

Not sure what "it" is in "storing and computing it inside the model definition". Complete distribution of these metrics?


drbenvincent commented on 2022-06-05T16:58:31Z
----------------------------------------------------------------

I've removed the last sentence

Copy link
Contributor Author

Done, in upcoming commit


View entire conversation on ReviewNB

Copy link
Contributor Author

removing this in upcoming commit


View entire conversation on ReviewNB

Copy link
Contributor Author

Agreed


View entire conversation on ReviewNB

Copy link
Contributor Author

Doesn't need to be because I used labels for the coefficient names. But here I agree, so I've changed them to b0, b1, b2, b1:b2


View entire conversation on ReviewNB

Copy link
Contributor Author

I've removed the last sentence


View entire conversation on ReviewNB

Copy link
Member

cluhmann commented Jun 5, 2022

I guess I meant that x1 here (i.e., idata.posterior.b.sel(coeffs="b1").mean().data) is the mean posterior of a coefficient that is labeled "b1", which is then multiplied by the "x1" taken from the grid (i.e., x1_grid). So I guess I assumed that idata.posterior.b.sel(coeffs="b1").mean().data would be stored in a variable named b1 rather than x1.

Also, as in the comment resolved above, I tend to do: idata.posterior["b"] rather than idata.posterior.b.


View entire conversation on ReviewNB

@review-notebook-app
Copy link

review-notebook-app bot commented Jun 5, 2022

View / edit / reply to this conversation on ReviewNB

juanitorduz commented on 2022-06-05T20:33:25Z
----------------------------------------------------------------

Line #2.    sns_c_div = sns.diverging_palette(240, 10, n=2)

When I wrote this notebook I was using the ugly sns_c[0] trick to get seaborn's colours instead of using the more convenient "C0" , which I think is much less confusing. So I would suggest to change it. Sorry, this one is on me :/


drbenvincent commented on 2022-06-05T21:36:23Z
----------------------------------------------------------------

Have moved to just using defaults throughout. It doesn't look as good, but do feel free to hold me accountable to improve it and stop me from being lazy

Copy link
Contributor Author

Have moved to just using defaults throughout. It doesn't look as good, but do feel free to hold me accountable to improve it and stop me from being lazy


View entire conversation on ReviewNB

@drbenvincent
Copy link
Contributor Author

Any final comments @juanitorduz? Or happy for me to merge this?

@juanitorduz
Copy link
Collaborator

LGTM 🚀

@drbenvincent
Copy link
Contributor Author

@OriolAbril I seem to have an approval from @cluhmann, but it says merging is blocked and that I don't have an approval.

@twiecki twiecki merged commit 75e0b9a into pymc-devs:main Jun 7, 2022
@drbenvincent drbenvincent deleted the glm-out-of-sample branch June 7, 2022 13:39
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.

4 participants