Code Monkey home page Code Monkey logo

Comments (6)

fonnesbeck avatar fonnesbeck commented on August 26, 2024

I think something along these lines would be feasible. Perhaps the most sensible way would be to change Stochastic.set_value method to accept an observed flag.

umbrella.set_value(True, observed=True)

I'm not opposed to your solution either, however, where it is set via the model rather than the stochastic. No reason we can't have both, I suppose. All this would have to do is move stochastics to and from the Model.stochastics and Model.observed_stochastics dictionaries.

from pymc2.

yarden avatar yarden commented on August 26, 2024

Either way sounds great. I'd be happy to try to implement this. Should it go in pymc or pymc3? I'm not totally sure of the relationship between the two - is pymc3 meant to replace pymc very soon? Is the plan to have pymc3 be backwards compatible with pymc?

from pymc2.

fonnesbeck avatar fonnesbeck commented on August 26, 2024

You can try to implement it in either version, though pymc will be easiest. pymc3 will eventually replace pymc, but they are likely to coexist for some time. It is a breaking update; though the syntax is very similar, you cannot simply run a pymc model under pymc3.

from pymc2.

marcus-r-kelly avatar marcus-r-kelly commented on August 26, 2024

I would also be interested in this feature for similar reasons to Yarden-- I am training a model with a given set of observations, and then testing how well other observations fit that model. In particular, it would be really useful to have a function to evaluate the logp of a model given observations that are not extrinsic to the model itself. Perhaps these could even be optional arguments passed to the logp function

@stochastic(observed=True)
def my_distribution(**kwargs):
    #etc.

my_distribution.logp
#^^ would evaluate with values used at initialization
my_distribution.logp(other_vaues)
#^^ evaluates with values =  other_values instead of those used at initialization

from pymc2.

tom-christie avatar tom-christie commented on August 26, 2024

I would also love to have this feature! It would be nice to see how the posterior shifts as new data is observed.

from pymc2.

fonnesbeck avatar fonnesbeck commented on August 26, 2024

What I generally do is wrap my model in a function, and use the dataset as an argument. That way, each instance of the model is associated with the new dataset. e.g.

def generate_model(dataset):

    <model declaration>

    # Likelihood
    y = Normal('y', mu, tau, value=dataset['y'], observed=True)

    return locals()

model1 = MCMC(generate_model(dataset1))
model2 = MCMC(generate_model(dataset2))

from pymc2.

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.