Question

I would like to estimate the parameters of a directed Bayes net using PyMC. I came across one particular example that implements the sprinkler network, which has 3 random variables and a conditional probability distribution (CPD) defined for each node.

However, this example has the CPD encoded using deterministic variables.

Is it possible to provide the joint or marginal distribution over 2 or 3 random variables as the observed data to a deterministic PyMC variable? In other words, if my network is of the form X -> Z <- Y, is it possible to provide a set of tuples of the form 'x1,y1,z1' as observed data, to learn the parameters of the CPD (Z|X,Y)?

Was it helpful?

Solution

The sprinkler example is really setting "Static" probability values. In this line:

p_G = mc.Lambda('p_G', lambda S=S, R=R: pl.where(S, pl.where(R, .99, .9), pl.where(R, .8, 0.)),
            doc='Pr[G|S,R]')

to my understanding, i think we would require to set learn one parameter for each value of the parent. so if we want to learn P(Z/X,Y), we will need for each combination of values of X and Y, learn one parameter set for Z. so lets say X and Y take boolean values and Z is a bernoulli distribution. for each value of (X,Y) , ie: (0,0),(0,1),(1,0),(1,1) we have parameters, p1,p2,p3,p4. And then Z has 4 pymc observed variables: Z1 with parameter p1, Z2 with parameter p2 , Z3 with parameter p3 and Z4 with parameter p4. Thus:

P(Z=0/X=0,Y=0) is the mcmc estimated mean of p1. 
P(Z=1/X=0,Y=0) = 1-p1
P(Z=0/X=1,Y=0) = p2 and so on....

I have a related question here: How to use pymc to parameterize a probabilistic graphical model?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top