Code Monkey home page Code Monkey logo

Comments (10)

twiecki avatar twiecki commented on July 17, 2024 3

Definitely the second, I don't think a user should have to remember to call the helper. In the previous we also deal with coords transparently.

from pymc-experimental.

zaxtax avatar zaxtax commented on July 17, 2024 1

Hmm, I think I'd rather keep the one model. Unless my current workflow is bad practice or I've missed the point:

m = model(data=data, coords=coords)
idata = pm.sample(
    model=m,
    return_inferencedata=True,
)

idata.extend(pm.sample_posterior_predictive(idata, model=m, predictions=False))

pm.set_data(new_data=data_predict, model=m)
idata.extend(pm.sample_posterior_predictive(idata, model=m, predictions=True))

tbf, I guess replacing the set_data line isn't a killer. Might be easier to keep track of one m though. Coming from R (sorry), I prefer one m: predict(m, newdata = new_data)

With either of the above workflows your code can look like this:

m = model(data=data, coords=coords)
idata = pm.sample(model=m)

pm.sample_posterior_predictive(idata, model=m, predictions=False, extend_inferencedata=True)
m_new = model(data=data_predict, coords=new_coords)
pm.sample_posterior_predictive(idata, model=m_new, predictions=True, extend_inferencedata=True)

from pymc-experimental.

theorashid avatar theorashid commented on July 17, 2024

I prefer the second. As long as it works for coords_mutable (and whatever other args we need) too.

from pymc-experimental.

ricardoV94 avatar ricardoV94 commented on July 17, 2024

You may have no need for coords_mutable with as_model since you can just build a different model with fixed coords for posterior predictive, as shown above with m_train and m_test

from pymc-experimental.

theorashid avatar theorashid commented on July 17, 2024

Hmm, I think I'd rather keep the one model. Unless my current workflow is bad practice or I've missed the point:

m = model(data=data, coords=coords)
idata = pm.sample(
    model=m,
    return_inferencedata=True,
)

idata.extend(pm.sample_posterior_predictive(idata, model=m, predictions=False))

pm.set_data(new_data=data_predict, model=m)
idata.extend(pm.sample_posterior_predictive(idata, model=m, predictions=True))

tbf, I guess replacing the set_data line isn't a killer. Might be easier to keep track of one m though. Coming from R (sorry), I prefer one m: predict(m, newdata = new_data)

from pymc-experimental.

fonnesbeck avatar fonnesbeck commented on July 17, 2024

I'm starting to appreciate @ricardoV94 's approach of simply having a prediction model that uses the trace of the fitted model, and not have to worry about changing coords.

I'm confused by the example above -- m_train and m_test appear to be two entirely separate model instances, with no shared parameters. How is m_test getting the trained parameters?

from pymc-experimental.

ricardoV94 avatar ricardoV94 commented on July 17, 2024

How is m_test getting the trained parameters?

That would happen when calling pm.sample_posterior_predictive with the idata from sampling

from pymc-experimental.

fonnesbeck avatar fonnesbeck commented on July 17, 2024

So the missing steps are:

trace = pm.sample(model=m_train)
pm.sample_posterior_predictive(trace, model=m_test, extend_inferencedata=True)

The nice thing here is that it avoids having to set up placeholder vars when you build a separate prediction model.

Yeah, I like the second one.

from pymc-experimental.

twiecki avatar twiecki commented on July 17, 2024

Still in favor of the second.

from pymc-experimental.

zaxtax avatar zaxtax commented on July 17, 2024

Thanks everyone for your feedback!

from pymc-experimental.

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.