import os
os.chdir("res")
import pyAgrum as gum
import pyAgrum.lib.notebook as gnb
O3PRM is inspired by relational language, directly based on the BN and improved by object oriented paradigms, where the focus is set on classes of objects and by defining relations among these objects (see http://o3prm.gitlab.io/ for more details)
with open('./Asia.o3prm','r') as prm:
for line in prm.readlines():
print(line,end="")
class Asia { boolean visitToAsia { [ 0.99, // False 0.01 ] // True }; boolean tuberculosis dependson visitToAsia { // False | True [ 0.99, 0.95, // False 0.01, 0.05 ] // True }; boolean smoking { [ 0.50, // False 0.50 ] // True }; boolean lungCancer dependson smoking { // False | True => smoking [ 0.99, 0.90, // False 0.01, 0.10 ] // True }; boolean bronchitis dependson smoking { // False | True => smoking [ 0.70, 0.40, // False 0.30, 0.60 ] // True }; boolean tubOrCancer dependson tuberculosis, lungCancer { // False || True => tuberculosis // False | True || False | True => lungCancer [ 1.00, 0.00, 0.00, 0.00, // False 0.00, 1.00, 1.00, 1.00 ] // True }; boolean positiveXRay dependson tubOrCancer { // False | True => tubOrCancer [ 0.95, 0.02, // False 0.05, 0.98 ] // True }; boolean dyspnea dependson tubOrCancer, bronchitis { // False || True => tubOrCancer // False | True || False | True => bronchitis [ 0.90, 0.20, 0.30, 0.10, // False 0.10, 0.80, 0.70, 0.90 ] // True }; }
bn=gum.loadBN("./Asia.o3prm",verbose=False)
bn
bn=gum.loadBN("./aSys.o3prm")
bn
classpath="./ComplexPrinters"
filename="./ComplexPrinters/fr/lip6/printers/system.o3prm"
system="Work"
bn=gum.loadBN(filename,system=system,classpath=classpath)
# the inference will take place in a rather large junction tree
gnb.showJunctionTreeMap(bn,scaleClique=0.1,scaleSep=0.05,lenEdge=1.2,size="8!")
gnb.showInference(bn,size="25!")