# How to do hidden variable learning in Bayesian Network with Python?

I learned how to use libpgm in general for Bayesian inference and learning, but I do not understand if I can use it for learning with hidden variable. More precisely, I am trying to implement approach for Social Network Analysing from this paper: Modeling Relationship Strength in Online Social Networks. They suggest to use following architecture

Here

• S(ij) represents vector of similarity between user i and j - Observed
• z(ij) is a hidden variable - relationship strength (Normal distribution regularised by W - weights and similarity vector)- Hidden
• yt(ij) is user interaction(1,2…n -> certain type of interaction e.g. 1=I retweeted j) (function of z and a that involves Theta parameter) - Observed
• at(ij) is auxiliary variable which represents how often certain interaction occurs - Observed

Approach described in paper for training is quite difficult and involves coding of ascent optimisation. I wonder If I can use libpgm to learn W and Theta parameters. If yes, how to do it? If no, what libraries I can use to do it.

While this model could be implementable in the libpgm library (it seems to have quite rigid interface tailored to several special models, though), it will not allow you to reproduce the results of this paper. In the paper authors actually do something way simpler than Bayesian Inference – they only perform maximum-aposteriori (MAP) inference, which is way easier, but does tell you how confident the model is.
All these methods will give you values (point estimates) of $$w, \theta, z$$ that you can use to make inferences. However, if you want to have more than point estimates, and would like to do find all possible values (along with their probabilities) and maybe Bayesian Model Averaging, you'll need more powerful libraries enabling probabilistic programming. There are Edward (built upon TensorFlow), Pyro (built upon PyTorch), Stan and others.