这篇博客很简单,接上一篇:在Ubuntu上安装并运行DeepProbLog的简单过程_蛐蛐蛐的博客-CSDN博客
其实要运行ProbLog代码是相当简单的,如上一篇博客中所说的,首先安装engine:
pip install problog
可以参考其GitHub repo:https://github.com/ML-KULeuven/problog 或者主页:Introduction. — ProbLog: Probabilistic Programming
安装好之后,例如我们想运行这里的例子:
https://github.com/ML-KULeuven/problog/tree/master/test
例如上一篇博客中提到的论文中的“alarm Bayesian network”,具体代码是这样:https://github.com/ML-KULeuven/problog/blob/master/test/4_1_bayesian_net.pl
- %System test 4 - a Bayesian network.
- %Description: The burglary-alarm-earthquake BN without any people. The alarm goes off in three different cases.
- %Query: what is the probability of burglary and what is probability of an earthquake
- %Evidence: we know that the alarm has gone off.
- %Expected outcome:
- % burglary 0.9896551724137932
- % earthquake 0.2275862068965517
- 0.7::burglary.
- 0.2::earthquake.
-
- 0.9::alarm <- burglary, earthquake.
- 0.8::alarm <- burglary, \+earthquake.
- 0.1::alarm <- \+burglary, earthquake.
-
-
- %%% Evidence
- evidence(alarm,true).
- %%% Queries
- query(burglary).
- query(earthquake).
那么只需要运行:
problog 4_1_bayesian_net.pl
就可以看到结果了。就先简单总结这么多。