Skip to content

Update Jupyter style in lasso notebook #279

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 4 commits into from
Mar 4, 2022
Merged

Update Jupyter style in lasso notebook #279

merged 4 commits into from
Mar 4, 2022

Conversation

ltoniazzi
Copy link
Member

@ltoniazzi ltoniazzi commented Feb 5, 2022

Addressing Issue #110

Upgrading with respect to the style guides and v4 practices to reach Best Practices. Main changes:

  • Changed some variables names to follow notation y = X * beta
  • Add myst references of some pymc classes (still need to fix them as they are not rendering correctly)
  • header, footer, authors...
  • removed start in pm.sample.

I am not sure if changes should be done with respect to v4. Can someone comment on that? @fonnesbeck @CloudChaoszero @michaelosthege

Helpful links

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@@ -4,40 +4,75 @@
"cell_type": "markdown",
Copy link
Member

Choose a reason for hiding this comment

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

Line #2.        initvals = pm.find_MAP()

it might be best to get rid of this completely instead of updating to use initvals. Is there any reason to use the map as initial point?


Reply via ReviewNB

Copy link
Member Author

Choose a reason for hiding this comment

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

I did, however as I side note, once I remove initvals, sometimes it runs correctly but also many times the sampling hangs and I get some warnings. Specifically, running:

with model:
    step1 = pm.Metropolis([beta1, beta2])
    step2 = pm.Slice([sigma, tau])
    idata = pm.sample(10000, step=[step1, step2])

I sometimes get three of these RuntimeWarnings

/home/user/miniconda3/envs/pymc-test-py39/lib/python3.9/site-packages/pymc/step_methods/metropolis.py:250: RuntimeWarning: overflow encountered in exp
  "accept": np.exp(accept),

and the sampling hangs.

Copy link
Member

Choose a reason for hiding this comment

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

Does this happen during tuning or during sampling?

Copy link
Member

@michaelosthege michaelosthege Feb 6, 2022

Choose a reason for hiding this comment

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

"accept": np.exp(accept)

That's probably an extreme value in the acceptance probability during MCMC. Since you're seeing this go away with MAP initivals, my best guess would be that the prior is far away from the typical set.

Looking at the traceplot below, that's most probably somethin with the "tau" parameter. The default initval for this U(0,1) variable will be 0.5, but the posterior is very close to 0.

Maybe because "lam" increased by 1000x?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the hints. The issue happens during sampling. Also, the lam scaling is equivalent to the original notebook, and I tried changing it to lam=1, leave only tau=HalfNormal(0,1) and some other combinations, but I still get this issue on most runs without initvals. You think I should put initvals back? Also, if I run pm.sample(10000) (without steps and initvals) everything works fine.

@OriolAbril OriolAbril merged commit ef1c532 into pymc-devs:main Mar 4, 2022
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