I am using Dirichlet distribution as a distribution over distributions in a Bayesian network. It models how material types (metal, plastic, etc…) connect with density, elasticity and so on.
Now I have another node, which I would also like to model with Dirichlet distribution, the Object category (e.g. bottle, wineglass, spoon, etc.). I have a correlation probability matrix that says how each material correlates with each category (i.e. how probable is it that some object is a bottle, if I know its from plastic and vice versa). I am not sure if I am using the word “correlation” correctly.
I would like to connect those two Dirichlet nodes together through this correlation probability matrix, but I did not find any easy solution for this within the PyMC3 API. I currently create a dummy Multinomial distribution which can accept an observation. The observation is sampled from a multinomial distribution that corresponds to the
category @ correlation_matrix, which is basically the category translated to material. This material dummy Multinomial is connected to the material Dirichlet distribution which changes all connected nodes with new observations. This is depicted in the second picture.
This is how I would like to connect the network inside the PyMC3 model. The problem I am describing is depicted in red color. I need both to be Dirichlet distribution in order to connect them with NormalMixtures “Density” and “Volume”.
On the picture below is how I solve the problem now, but it puts the left part out from the model. I do not want to have two PyMC3 models, the system is a Bayesian network that should be wholly connected in one model.
I am looking for a solution that would look something like this:
T1 # transition matrix material_given_category T2 # transition matrix category_given_material with pm.Model() as model: material = pm.Dirichlet('mat', w=alphas1) category = pm.Dirichlet('cat', w=alphas2) pm.ConnectDirichlet(material, category, [T1, T2]) # this line is totally made up density = pm.NormalMixture('density', w=material, mu=mus, sigma=sigmas, observed=observation_density) volume = pm.NormalMixture('volume', w=category, mu=mus_2, sigma=sigmas_2)
Could you please direct me in the direction of solving this problem in a PyMC3 manner? I would like to make my code as general as possible. Thank you.