Bayesian network package ~ Pebl tutorial execution ~

Last time, there was a story about using Markov chains in the Attribution Model, so I made a simple touch. It seems that some Attribution Models use Bayesian networks, so I would like to check their packages and how to use them. For the Bayesian network itself, check out various articles and books. You can search by the Bayesian network itself, or you can find related ones in the graphical model.

Python package

It seems that there are these two. First of all, I would like to see it using Pebl. Pebl

Installation

OS: Ubuntu16.0.4


anaconda: 3-4.1.0
python: 2.7.12
pydot: 1.0.28
numpy: 1.11.1```
 is.

 I installed the following packages related to the main unit.
```pip install pebl
conda install Graphviz
pip install simple_json```
 * The nose_test did not pass, but the Tutorial was able to be executed.
### Usage data
 I would like to check the sample data while looking at the [Tutorial on the official page](http://pythonhosted.org/pebl/tutorial.html).
 From there, DL "pebl-tutorial-data1.txt" and store it in the directory to be executed.
 This is genomic test data, which looks like 76 rows and 12 columns. Unfortunately, I didn't understand the column names.
### Execution example
 Next, run the Tutorial test data.
 The command ʻex1result.tohtml ("example1-result") `in First Example gave the following error.

#### **`/home/usrname/.pyenv/versions/anaconda3-4.1.0/envs/py27/lib/python2.7/site-packages/pebl/network.pyc in layout(self, width, height, dotpath)`**
287         dotgraph = pydot.graph_from_dot_file(dot2)
288         nodes = (n for n in dotgraph.get_node_list() if n.get_pos())
--> 289         self.node_positions = [[int(i) for i in n.get_pos()[1:-1].split(',')] for n in nodes]
290
291 ```

It seems that the cause of the error is that the floating point of the character string (such as '99.9') is put in int (). I can't help it, so I made changes to the relevant line. There was a possibility that the output would be slightly different from the reference one, but I was able to execute it.

Change before) self.node_positions = [[int(i) for i in n.get_pos()[1:-1].split(',')] for n in nodes]


 (After change) self.node_positions = [[int (round (i)) for i in n.get_pos () [1: -1] .split (',')] for n in nodes] `` `

 The Tutorial turned around and the html file was output.
 Log Score etc. came out, but I can not read it unless I understand the meaning of this area, so I have to check that area as well. .. ..


Recommended Posts

Bayesian network package ~ Pebl tutorial execution ~
[Go] Execution / build / package test
pgmpy: Discrete Bayesian Network Trial-Inference
Pytorch Neural Network (CNN) Tutorial 1.3.1.