Giter Club home page Giter Club logo

Comments (4)

brendan-m-murphy avatar brendan-m-murphy commented on August 19, 2024 1

If your postererior_predictive is InferenceData type, then try something like: az.plot_dist(posterior_pred_values.sum('y_obs_dim_0').isel(chain=0).y_obs). Each observation is a Bernoulli, but there is a coordinate y_obs_dim_0 (or something similar) whose length is the number of trials. If you sum over this axes, then you get Binomial samples with n=20 (or however many samples were in your observed data used for the likelihood function).

from bookcode_edition1.

aaelony avatar aaelony commented on August 19, 2024 1

Thank-you, @brendan-m-murphy that was very helpful.

The following with var_names appears to work in PyMC 5:

pred_dists = (
    pm.sample_prior_predictive(1000, model).prior_predictive["y_obs"],
    pm.sample_posterior_predictive(idata, model, var_names = ["y_obs"])
)

Likewise,

pm.sample_prior_predictive(1000, model, var_names=["y_obs"]).prior_predictive

with the var_names arg seems to work as well.

Cheers,
Avram

from bookcode_edition1.

aaelony avatar aaelony commented on August 19, 2024

Is there erratum for the book using the pymc library?

The book code on page 12 (Code 1.7) below gives an error of: KeyError: 'y_obs'

pred_dists = (                                                                                                                                       
    pm.sample_prior_predictive( 1000, model)["y_obs"],                                                                                                    
    pm.sample_posterior_predictive(idata, 1000, model)["y_obs"]                                                                                           
)                                                                                                                                                        

from bookcode_edition1.

brendan-m-murphy avatar brendan-m-murphy commented on August 19, 2024

@aaelony The "sample_ ... _predictive" functions return arviz inference data, so you need to use e.g. pm.sample_prior_predictive(1000, model).prior_predictive["y_obs"] (I think.)

Also, for PyMC 5, it seems like you need to use pm.sample_posterior_predictive(idata, model). There is no argument to specify the number of samples (I think it just gives you the same number of posterior predictive samples as samples in the idata, so 1000 samples per chain by default).

from bookcode_edition1.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.