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

Bayesian Methods for Reliability Data #474

Closed
NathanielF opened this issue Dec 14, 2022 · 13 comments
Closed

Bayesian Methods for Reliability Data #474

NathanielF opened this issue Dec 14, 2022 · 13 comments
Labels
proposal New notebook proposal still up for discussion

Comments

@NathanielF
Copy link
Contributor

Notebook proposal

Bayesian Methods fo reliability Data

This topic crops up in engineering quite a bit and generally involves a spin on survival analysis (time to failure) type models, but it's also tightly linked with the notion of cost-benefit, since there is a tolerable degree of failure. I was thinking about riffing on a discussion about prediction intervals for failure analysis in:

https://www.wiley.com/en-us/Statistical+Methods+for+Reliability+Data,+2nd+Edition-p-9781118115459

and contrast the frequentist and Bayesian approach to calibrated prediction. It might be interesting to contrast conformal prediction methods too, since it is a frequentist approach to uncertainty quantification which is getting quite a bit of coverage lately.

Suggested categories:

  • Level: Intermediate
  • Diataxis type: explanation

Related notebooks

It might have cross over in themes with: #407
and some of the techniques for modelling the failure predictions draw on survival analysis models.

@NathanielF NathanielF added the proposal New notebook proposal still up for discussion label Dec 14, 2022
@OriolAbril
Copy link
Member

I think it would be a great addition, and it is a great fit for an explanation type notebook (that can/could complement other how-to notebooks on generating predictions for different kind of models for example).

NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Dec 31, 2022
NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Dec 31, 2022
NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Dec 31, 2022
NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Dec 31, 2022
NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Dec 31, 2022
NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Dec 31, 2022
NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Dec 31, 2022
NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Dec 31, 2022
NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Dec 31, 2022
NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Dec 31, 2022
NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Dec 31, 2022
…ons failing to recover good fits.

Signed-off-by: Nathaniel <[email protected]>
@NathanielF NathanielF mentioned this issue Dec 31, 2022
3 tasks
@NathanielF
Copy link
Contributor Author

Did a little work on this over the Christmas holidays. Written up a brief discussion of nonparametric and parametric estimation of reliability distributions and their CDFs. I'm following an example in the book cited above which moves through the frequentist MLE style estimation to a data set with very few failures... it argues for the importance of Bayesian modelling in this case especially.... so I think it's a good example for here.

However, I'm stuck a bit on trying to replicate the model fits achieved in the book or bring them anywhere close to the MLE fits. I'm using a Weibull survival model and I've tried (a) to replicate the stan model they use in the book (b) just use a base pymc weibull fit adding a potential for lcdf portion of the log likelihood and (c) use the censored model transformation as discussed in one of the survival analysis notebooks by @drbenvincent . I've use both period form and item-period data sets as described in the notebook, but none seem to recover good model fits with the pymc implementation...

I reckon I must be doing something silly so would appreciate any pointers you might have.

NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Jan 1, 2023
@NathanielF
Copy link
Contributor Author

Think the above discussed issue is resolved now:
image

image

Now just need to write up the contrasting perpsectives on prediction intervals.

NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Jan 2, 2023
NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Jan 3, 2023
NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Jan 3, 2023
NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Jan 4, 2023
NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Jan 4, 2023
NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Jan 4, 2023
@NathanielF
Copy link
Contributor Author

Ok, i've been banging my head against pre-commit issues on this pull request for a while now. I don't really understand it either since the tests appear to be passing for me locally:

image

But when they run in the cloud it breaks on the jupytext test where it says the myst notebook git index is out of date...

any idea why this might be happening @OriolAbril?

NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Jan 5, 2023
@NathanielF
Copy link
Contributor Author

Some more context on the error. It crashes out with the message here:

image

But should the paired notebook not appear in the myst nb directory rather than the examples/case_studies directory?

NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Jan 5, 2023
NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Jan 5, 2023
NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Jan 5, 2023
NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Jan 5, 2023
NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Jan 5, 2023
@NathanielF
Copy link
Contributor Author

I suspect the issue has something to do with the metadata like discussed here: mwouts/jupytext#900

My version of jupytext:

image

Couldn't easily find which version of juyptext the runner is using?

NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Jan 5, 2023
NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Jan 5, 2023
NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Jan 6, 2023
NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Jan 6, 2023
NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Jan 6, 2023
NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Jan 6, 2023
NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Jan 6, 2023
…sor and updated jupytext.toml

Signed-off-by: Nathaniel <[email protected]>
@NathanielF
Copy link
Contributor Author

Ok, fixed the git index issue. Finally realised there was no more msyt notebooks directory on main. But now the docs won't build because it's failing on the watermark extension:

image

@NathanielF
Copy link
Contributor Author

NathanielF commented Jan 6, 2023

Think some of these issues are due to the fact that the Head of the main branch does not reflect the actual latest commit where @drbenvincent has added the template notebook and the myst directory has been removed.

image

I mean, i have no idea why the watermark extension is failing in sphinx, but there is a break in the directory structure and the jupytext configuration that is not currently being read as the most updated branch.

NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Jan 6, 2023
NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Jan 6, 2023
…e notebook to myst folder.

Signed-off-by: Nathaniel <[email protected]>
@NathanielF
Copy link
Contributor Author

NathanielF commented Jan 6, 2023

Ok, to summarise my findings so far:

When i had the old configuration the sphinx docs would build successfully but the pre-commit checks would fail because jupytext expected a note book in the examples/ directory.

The pre-commit checks fail unless there is a myst notebook in the examples/ folder.
The old jupytext specification added the myst notebook to the myst directory. Changing the jupytext configuration the one visible on github seems to solve the issue of pre-commit checks and populates the notebook in the examples directory. However, now the sphinx doc build started to fail with the %load extension error. I don't understand why this would be the case but assume it has something to do with the mismatch between commits?

Going to try branching off the latest commit and start a new pull request

NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Jan 6, 2023
@NathanielF
Copy link
Contributor Author

Branching off the latest commit seemed to work to resolve the pre-commit issues!!!

NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Jan 7, 2023
@OriolAbril
Copy link
Member

Sorry for not seeing this before. Yeah, we recently changed the way pre-commit and jupytext worked because it was often a source of conflicts. It should now be simpler in that running pre-commit will always fix the jupytext step (like black for example), but you have needed to rebase and get rid of the myst_nbs notebook and of the doc build folder (if you built the docs locally).

@NathanielF
Copy link
Contributor Author

All sorted now. Thanks!

@NathanielF
Copy link
Contributor Author

New pull request with passing commit checks is ready for review here:#491

NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Jan 9, 2023
…hide data import and plotting funcs

Signed-off-by: Nathaniel <[email protected]>
NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Jan 9, 2023
NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Jan 12, 2023
…diction intervals with posterior predictive intervals

Signed-off-by: Nathaniel <[email protected]>
NathanielF added a commit to NathanielF/pymc-examples that referenced this issue Jan 16, 2023
OriolAbril added a commit that referenced this issue Jan 16, 2023
* [Reliability Bayesian #474] Adding notebooks and bib on clean branch

Signed-off-by: Nathaniel <[email protected]>

* [Reliability Bayesian #474] added cost function plot and varied priors.

Signed-off-by: Nathaniel <[email protected]>

* [Reliability Bayesian #474] updated with review comments to hide data import and plotting funcs

Signed-off-by: Nathaniel <[email protected]>

* [Reliability Bayesian #474] updated final plot to display nicer in thumbnail

Signed-off-by: Nathaniel <[email protected]>

* [Reliability Bayesian #474] added text to link bootstrap prediction intervals with posterior predictive intervals

Signed-off-by: Nathaniel <[email protected]>

* update bayesian predictions to use einstats

* [Reliability Bayesian #474] fixed minor typo

Signed-off-by: Nathaniel <[email protected]>

* Update reliability_and_calibrated_prediction.myst.md

Fixed typo on myst too

Signed-off-by: Nathaniel <[email protected]>
Co-authored-by: Oriol (ZBook) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal New notebook proposal still up for discussion
Projects
None yet
Development

No branches or pull requests

2 participants