aloctavodia / BAP

Bayesian Analysis with Python (Second Edition)
https://www.amazon.com/dp/B07HHBCR9G
MIT License
646 stars 251 forks source link

arviz._fast_kde deprecated #69

Closed antortjim closed 2 years ago

antortjim commented 4 years ago

Dear Osvaldo

Thank you for writing BAP. I am learning a lot!

I wanted to point out an error I am getting with this line in the last cell of Chapter 3

density, l, u = az._fast_kde(y_ppc)

the _fast_kde is deprecated and does not exist anymore in arviz 0.9.0 (latest version as of Jul 28 2020). What would be the equivalent in the new versions of arviz? Or maybe we need to use another module to retrieve the kernel density estimate from a pymc3 trace?

Thank you!

aloctavodia commented 4 years ago

I am glad you find the book useful. _fast_kde is now at az.numeric_utils._fast_kde. I will add a folder to this repo with an updated version of the code ASAP.

antortjim commented 4 years ago

Great thanks! Keep up the good work! :smile: Saludos

ammuth commented 2 years ago

Hi @aloctavodia , I have been using your BAP code quite frequently now as I am working on a directed study regarding NCAA basketball offensive ratings. I did want to ask--as I see this was asked earlier this year already--how I should fix the last line of code in Chapter 3 (density, l, u = az._fast_kde(y_ppc))? I have also run into the issue where I get an error saying:

module 'arviz' has no attribute '_fast_kde'

I just wanted to ask and see if there's anything you'd recommend in terms of fixing the code itself, or if there's a different version of arviz I need to be using, along with other packages.

Thank you!

aloctavodia commented 2 years ago

Hi @ammuth at the beginning of the book there is a list of packages, with their versions, used in the book. The code should run without errors if you install those packages. There is also an environmental file bap.yml in this repository that you can use to create an environment with all the needed packages.

In case you want to run the the last stable version of PyMC, and the last stable version of ArviZ that works with that I have created a directory in this repository code_3_11 where I will add updated versions of the code.

ammuth commented 2 years ago

Hi @aloctavodia thank you so much that did the trick and everything seems good to me! I did have another quick question not related to any syntax issues--it's okay if you don't have an answer for this, but for my project I would like to do a MLR with 5 variables, and a few of them have non constant variance when plotted with my y variable. As in Chapter 3 with the discussion and code of multiple linear regression variable variance and the example of baby month vs length--I wanted to ask if you would know how to go about altering the code from page 126 and 139 so I could account for non-constant variance while having more than one dependent variable?

aloctavodia commented 2 years ago

@ammuth glad everything is working now. In principle you can model the mean or variance as a linear model of more than one variable. In the book the examples are only for the mean, which is the most common scenario.