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 weibull_aft notebook #4020

Merged
merged 3 commits into from
Jul 24, 2020
Merged

Conversation

AmitKus
Copy link
Contributor

@AmitKus AmitKus commented Jul 19, 2020

  1. Fixed: AttributeError: module 'statsmodels' has no attribute 'datasets'
  2. Fixed: FutureWarnings
  3. Updated the notebook to follow the consistent style (https://github.com/pymc-devs/pymc3/wiki/PyMC's-Jupyter-Notebook-Style)

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

Review Jupyter notebook visual diffs & provide feedback on notebooks.


Powered by ReviewNB

Copy link
Contributor

@AlexAndorra AlexAndorra left a comment

Choose a reason for hiding this comment

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

Thanks @AmitKus, this looks good! I just posted some comments below -- should be easy to address.
Tests are failing because of a Matplotlib issue, unrelated to your changes. Once #4023 is merged, you can rebase your current branch off master to take the changes into account and the tests should pass 😉

@review-notebook-app
Copy link

View / edit / reply to this conversation on ReviewNB

AlexAndorra commented on 2020-07-20T20:37:05Z
----------------------------------------------------------------

az.plot_trace(data_1, var_names=["alpha", "beta"]) outside of the model context would be better than pm.traceplot(trace_1, var_names=["alpha", "beta"]) inside the model context


@review-notebook-app
Copy link

View / edit / reply to this conversation on ReviewNB

AlexAndorra commented on 2020-07-20T20:37:06Z
----------------------------------------------------------------

Use az.summary(data_1, var_names=["alpha", "beta"], round_to=2) instead


@review-notebook-app
Copy link

View / edit / reply to this conversation on ReviewNB

AlexAndorra commented on 2020-07-20T20:37:07Z
----------------------------------------------------------------

Same comment as model 1 for plot_trace


@review-notebook-app
Copy link

View / edit / reply to this conversation on ReviewNB

AlexAndorra commented on 2020-07-20T20:37:07Z
----------------------------------------------------------------

Same comment as model 1 for summary


@review-notebook-app
Copy link

View / edit / reply to this conversation on ReviewNB

AlexAndorra commented on 2020-07-20T20:37:08Z
----------------------------------------------------------------

Same comment as model 1 for plot_trace


@review-notebook-app
Copy link

View / edit / reply to this conversation on ReviewNB

AlexAndorra commented on 2020-07-20T20:37:09Z
----------------------------------------------------------------

Same comment as model 1 for summary


@AmitKus
Copy link
Contributor Author

AmitKus commented Jul 21, 2020

Thanks @AmitKus, this looks good! I just posted some comments below -- should be easy to address.
Tests are failing because of a Matplotlib issue, unrelated to your changes. Once #4023 is merged, you can rebase your current branch off master to take the changes into account and the tests should pass wink

Thanks @AlexAndorra for taking out time to review the changes. I made the changes you had suggested.

@codecov
Copy link

codecov bot commented Jul 21, 2020

Codecov Report

Merging #4020 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #4020   +/-   ##
=======================================
  Coverage   86.77%   86.77%           
=======================================
  Files          88       88           
  Lines       14134    14134           
=======================================
  Hits        12265    12265           
  Misses       1869     1869           

@AlexAndorra
Copy link
Contributor

Thanks @AmitKus ! However, I don't think you rebased your branch -- you just picked up Robert's changes and integrated them into your PR. But these changes are already on the latest master. See what I mean?
I'm no git wizard, but I think you need to rebase your PR, i.e base it on the latest version of master, not on the one you originally based it on. That way, the MPL issue will already be taken care of. Note that you may have to revert your changes and add them back again but I'm not sure.
Sorry if this is confusing but you'll get the hang of it with time 😉

…sets'

2. Fixed: FutureWarnings
3. Updated the notebook to follow the consistent style

using arviz functions directly to plot trace and summary

1. Fixed: AttributeError: module 'statsmodels' has no attribute 'datasets'
2. Fixed: FutureWarnings
3. Updated the notebook to follow the consistent style

using arviz functions directly
@AmitKus
Copy link
Contributor Author

AmitKus commented Jul 21, 2020

Thanks @AmitKus ! However, I don't think you rebased your branch -- you just picked up Robert's changes and integrated them into your PR. But these changes are already on the latest master. See what I mean?
I'm no git wizard, but I think you need to rebase your PR, i.e base it on the latest version of master, not on the one you originally based it on. That way, the MPL issue will already be taken care of. Note that you may have to revert your changes and add them back again but I'm not sure.
Sorry if this is confusing but you'll get the hang of it with time wink

Thanks for your patience @AlexAndorra :)
I followed the link and rebased by PR. Hopefully this works!

Copy link
Contributor

@AlexAndorra AlexAndorra left a comment

Choose a reason for hiding this comment

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

Well done @AmitKus, the git log looks all good now 👏
This is almost ready -- just left a few comments to address before merging 😉

@review-notebook-app
Copy link

review-notebook-app bot commented Jul 22, 2020

View / edit / reply to this conversation on ReviewNB

AlexAndorra commented on 2020-07-22T08:55:21Z
----------------------------------------------------------------

It seems that pandas and patsy are imported but not used, in which case it's better to delete their import lines (ignore this if I'm mistaken)


@review-notebook-app
Copy link

review-notebook-app bot commented Jul 22, 2020

View / edit / reply to this conversation on ReviewNB

AlexAndorra commented on 2020-07-22T08:55:21Z
----------------------------------------------------------------

  • Sorry, just thought about something I should have told in my previous review: actually you can tell sample to directly give back an InferenceData object, instead of having to then call az.from_pymc3 . Just use: data_1 = pm.sample(target_accept=0.9, init="adapt_diag", return_inferencedata=True) . Note that I deleted tune and draws because their default is already 1000.
  • Accordingly, change the comment to: # Change init to avoid divergences

These comments are valid for all the other models ;)


AmitKus commented on 2020-07-22T17:39:26Z
----------------------------------------------------------------

Hi Alex, Looks like the default for tune and draws is 500, so made all the changes that you recommended except deleting draws and tune.

Thanks,

Amit

@review-notebook-app
Copy link

View / edit / reply to this conversation on ReviewNB

AlexAndorra commented on 2020-07-22T08:55:22Z
----------------------------------------------------------------

  • Use round_to=2 arg instead of .round(2) -- more idiomatic ;)

This comment is valid for all calls to az.summary 


Copy link
Contributor Author

AmitKus commented Jul 22, 2020

Hi Alex, Looks like the default for tune and draws is 500, so made all the changes that you recommended except deleting draws and tune.

Thanks,

Amit


View entire conversation on ReviewNB

@AlexAndorra
Copy link
Contributor

Thanks @AmitKus! This is weird though, the new default is 1000 for both tune and draws.
Which version of PyMC are you running? Can you post a screenshot of the progress bar when using the defaults please?

Copy link
Contributor Author

AmitKus commented Jul 23, 2020

Hey Alex, I just looked at the documentation for version 3.8 here: https://docs.pymc.io/api/inference.html

If this has changed in the recent version then I'll update the code to remove tune and draw.

Sampling

pymc3.sampling.sample(draws=500, step=None, init='auto', n_init=200000, start=None, trace=None, chain_idx=0, chains=None, cores=None, tune=500, progressbar=True, model=None, random_seed=None, discard_tuned_samples=True, compute_convergence_checks=True, **kwargs)

@AlexAndorra
Copy link
Contributor

Aaaaah ok, I see the confusion! Docs are actually not up-to-date with the latest version of the code yet (we're still updating some notebooks, as this one, so that they appear on the website when we compile the docs).
So, when running this NB with 3.9.2, you should be able to just pm.sample and the defaults of tune and draws should be 1000 👌

… they were using specifying the default values.
@AmitKus
Copy link
Contributor Author

AmitKus commented Jul 24, 2020

Aaaaah ok, I see the confusion! Docs are actually not up-to-date with the latest version of the code yet (we're still updating some notebooks, as this one, so that they appear on the website when we compile the docs).
So, when running this NB with 3.9.2, you should be able to just pm.sample and the defaults of tune and draws should be 1000 ok_hand

I see. Made the changes to remove the tune and draws.

Copy link
Contributor

@AlexAndorra AlexAndorra left a comment

Choose a reason for hiding this comment

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

This is super nice now 🎉 Thanks for your help @AmitKus !

@AlexAndorra AlexAndorra merged commit 6f8a0f7 into pymc-devs:master Jul 24, 2020
@AmitKus AmitKus deleted the weibull-aft branch July 24, 2020 18:41
@AmitKus
Copy link
Contributor Author

AmitKus commented Jul 24, 2020

This is super nice now tada Thanks for your help @AmitKus !

Great! Thanks for all the help @AlexAndorra

@kyleabeauchamp kyleabeauchamp added this to the 3.9.3 milestone Jul 28, 2020
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