Skip to content

Conversation

@AlexAndorra
Copy link
Contributor

@AlexAndorra AlexAndorra commented Jun 13, 2020

Ready for review 🍾
There is a lot of new material in this chapter. Most of these novelties are in sections 3 (instrumental variables), 4 (social relations models) and 5 (GPs), so I'd recommend focusing most of the reviewing efforts there.
Thanks in advance for the reviews 🖖

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

Review Jupyter notebook visual diffs & provide feedback on notebooks.


Powered by ReviewNB

@canyon289
Copy link
Member

Did a quick skim and things generally look good. Will do a deeper review this week, hopefully in next couple of days

@AlexAndorra AlexAndorra marked this pull request as ready for review June 15, 2020 21:12
@review-notebook-app
Copy link

review-notebook-app bot commented Jun 29, 2020

View / edit / reply to this conversation on ReviewNB

aloctavodia commented on 2020-06-29T16:01:19Z
----------------------------------------------------------------

Typo "extracts the stds and matrix"


@review-notebook-app
Copy link

review-notebook-app bot commented Jun 29, 2020

View / edit / reply to this conversation on ReviewNB

aloctavodia commented on 2020-06-29T16:01:20Z
----------------------------------------------------------------

Reading this I remember I have an unanswered question (https://github.com/aloctavodia/BAP/issues/68) :man-facepalming:

Shouldn't this be

np.exp(- 0.5 * post["rhosq"][::50].values[:, None] * x_seq ** 2)

and in the model definition

cov = etasq * pm.gp.cov.ExpQuad(input_dim=1, ls_inv=rhosq)

In the book rhosq=1.31, 1.31*0.5=0.65 (the value in this notebook), so maybe the only missing part is multiplying by 0.5


AlexAndorra commented on 2020-06-29T18:32:50Z
----------------------------------------------------------------

Indeed, this makes sense, thanks for catching this! Also, good to know we can parametrize the ExpQuad kernel with ls_inv!

@review-notebook-app
Copy link

review-notebook-app bot commented Jun 29, 2020

View / edit / reply to this conversation on ReviewNB

aloctavodia commented on 2020-06-29T16:01:21Z
----------------------------------------------------------------

typo "..And we can easily use this function in our model below" or "..And we can easily call this function in our model below"


@review-notebook-app
Copy link

review-notebook-app bot commented Jun 29, 2020

View / edit / reply to this conversation on ReviewNB

aloctavodia commented on 2020-06-29T16:01:22Z
----------------------------------------------------------------

Typo "...which is why I changed it" or "that's why I changed it"


Copy link
Contributor Author

Indeed, this makes sense, thanks for catching this! Also, good to know we can parametrize the ExpQuad kernel with ls_inv!


View entire conversation on ReviewNB

@AlexAndorra
Copy link
Contributor Author

Thanks for the review @aloctavodia ! I corrected the typos and implemented the changes on the GP for Oceanic tools model. It turns out that:

  • the prior for rhosq is super important as there isn't a lot of data. I changed it from Exponential(0.5) (as in the book) to HalfNormal(2) and results are looking much closer to the book, as does the posterior for rhosq.
  • I was using Dmatsq (squared distance) instead of Dmat (simple distance) to evaluate the GP.
  • In posterior predictive plots, it looks like etasq and rhosq should not be squared: they are implicitly modeled as the square in the model -- notice that Richard doesn't square them in his implementation of cov_GPL2.
  • Multiplying by 0.5 to make PPC plots look closer to the formula for ExpQuad kernel does improve the results -- note however that Richard doesn't do that in his implementation 🤷‍♂️

I think that there are subtle differences in the GP implementations between PyMC and ULAM that make a bijective match hard to get, but I think this looks quite good now!
If you agree with my changes, I'll rerun the whole NB and reformat it properly 🖖

@AlexAndorra
Copy link
Contributor Author

AlexAndorra commented Jul 1, 2020

@aloctavodia, as discussed I just pushed the change where rhosq = pm.Deterministic("rhosq", 0.5 * ls_inv ** 2). This has the nice of property of recovering the exact formula for the ExpQuad kernel, but makes the results less similar to the book's.
This looks good enough to merge though, and we can refine the implementation even more later. Also, I reran the whole NB.
Thanks for the review 🖖

@aloctavodia
Copy link
Member

There is a change to chapter 11's notebook that should not be part of this PR, right?

@AlexAndorra
Copy link
Contributor Author

Yeah it should -- it's just a super tiny typo fix, so I figured it wasn't worth a dedicated PR. Thanks for approving --> merging! 🍾

@AlexAndorra AlexAndorra merged commit b809179 into pymc-devs:master Jul 1, 2020
@AlexAndorra AlexAndorra deleted the chp14-2nd-ed branch July 1, 2020 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants