项目作者: thiagopbueno

项目描述 :
BN++ Data Structures and Algorithms in C++ for Bayesian Networks
高级语言: C++
项目地址: git://github.com/thiagopbueno/bn-pp.git
创建时间: 2016-03-02T16:10:50Z
项目社区:https://github.com/thiagopbueno/bn-pp

开源协议:GNU General Public License v3.0

下载


bn-pp

BN++ Data Structures and Algorithms in C++ for (discrete) Bayesian networks and Markov networks.

Compilation

  1. $ make clean && make

Usage

Bayes nets

  1. $ ./bn -h
  2. usage: ./bn /path/to/model.uai [/path/to/evidence.uai.evid TASK] [OPTIONS]
  3. TASK:
  4. -pr solve partition task
  5. -mar solve marginals task
  6. OPTIONS:
  7. -ls compute partition using logical sampling
  8. -lw compute partition using (bounded-variance) likelihood weighting
  9. -gs compute partition using gibbs sampling
  10. -sp compute marginals using sum-product in factor graphs
  11. -ve compute inference using variable elimination
  12. -mf variable elimination using min-fill heuristic
  13. -wmf variable elimination using weighted min-fill heuristic
  14. -md variable elimination using min-degree heuristic
  15. -bb variable elimination using bayes-ball
  16. -h display help information
  17. -v verbose

To inspect the markov assumptions of asia model

  1. $ ./bn ../models/asia.uai -v <../models/asia.markov.query >markov.result.txt

To check the local markov independencies of asia model

  1. $ ./bn ../models/asia.uai <../models/asia.ind

To check variable dependencies of asia model

  1. $ ./bn ../models/asia.uai <../models/asia.not.ind

To execute queries or check (in)dependencies on the prompt

  1. $ ./bn ../models/asia.uai -ve -bb
  2. >> Query prompt:
  3. ? query 1 | 0, 2
  4. P(1|0,2) =
  5. Factor(width:2, size:4, partition:2)
  6. 1 0
  7. 0 0 : 0.99000
  8. 0 1 : 0.95000
  9. 1 0 : 0.01000
  10. 1 1 : 0.05000
  11. >> Executed in 0.04897ms.
  12. ? query 2, 3, 4
  13. P(2,3,4) =
  14. Factor(width:3, size:8, partition:1.00000)
  15. 2 3 4
  16. 0 0 0 : 0.34650
  17. 0 0 1 : 0.14850
  18. 0 1 0 : 0.00350
  19. 0 1 1 : 0.00150
  20. 1 0 0 : 0.18000
  21. 1 0 1 : 0.27000
  22. 1 1 0 : 0.02000
  23. 1 1 1 : 0.03000
  24. >> Executed in 0.05496ms.
  25. ? ind 7,1|4,5
  26. true
  27. ? ind 4,1|6
  28. false
  29. ? quit

Markov nets

  1. $ ./mn
  2. usage: ./mn /path/to/model.uai /path/to/evidence.evid [OPTIONS]
  3. OPTIONS:
  4. -h display help information
  5. -v verbose

To compute the partition function of a Markov network given evidence

  1. $ ./mn ../models/grid3x3.uai ../models/grid3x3-PR.uai.evid
  2. >> Query prompt:
  3. ? PR
  4. partition = 14.8899
  5. >> Executed in 1.3077ms.

To compute the all the marginals of a Markov network given evidence

  1. $ ./mn ../models/grid3x3.uai ../models/grid3x3-MAR.uai.evid
  2. >> Query prompt:
  3. ? MAR
  4. >> Marginals:
  5. Factor(width:0, size:1, partition:1)
  6. : 1.00000
  7. Factor(width:1, size:2, partition:1.00000)
  8. 1
  9. 0 : 0.00011
  10. 1 : 0.99989
  11. Factor(width:1, size:2, partition:1.00000)
  12. 2
  13. 0 : 0.17139
  14. 1 : 0.82861
  15. Factor(width:0, size:1, partition:1.00000)
  16. : 1.00000
  17. Factor(width:0, size:1, partition:1.00000)
  18. : 1.00000
  19. Factor(width:1, size:2, partition:1.00000)
  20. 5
  21. 0 : 0.42988
  22. 1 : 0.57012
  23. Factor(width:1, size:2, partition:1.00000)
  24. 6
  25. 0 : 0.99122
  26. 1 : 0.00878
  27. Factor(width:1, size:2, partition:1.00000)
  28. 7
  29. 0 : 0.99995
  30. 1 : 0.00005
  31. Factor(width:1, size:2, partition:1.00000)
  32. 8
  33. 0 : 0.57011
  34. 1 : 0.42989
  35. >> Executed in 2.73007ms.

Input

The input format is the uai model specification for BAYES and MARKOV networks UAI 2014 Inference Competition.