compare: Compare two different Bayesian networks

Description Usage Arguments Value Author(s) References Examples

Description

Compare two different Bayesian networks; compute the Structural Hamming Distance (SHD) between them or the Hamming distance between their skeletons.

Usage

1
2
3
4
5
6
compare(target, current, arcs = FALSE)
## S3 method for class 'bn'
all.equal(target, current, ...)

shd(learned, true, debug = FALSE)
hamming(learned, true, debug = FALSE)

Arguments

target, learned

an object of class bn.

current, true

another object of class bn.

...

extra arguments from the generic method (currently ignored).

debug

a boolean value. If TRUE a lot of debugging output is printed; otherwise the function is completely silent.

arcs

a boolean value. See below.

Value

compare returns a list containing the number of true positives (tp, the number of arcs in current also present in target), of false positives (fp, the number of arcs in current not present in target) and of false negatives (tn, the number of arcs not in current but present in target) if arcs is FALSE; or the corresponding arc sets if arcs is TRUE.

all.equal returns either TRUE or a character string describing the differences between target and current.

shd and hamming return a non-negative integer number.

Author(s)

Marco Scutari

References

Tsamardinos I, Brown LE, Aliferis CF (2006). "The Max-Min Hill-Climbing Bayesian Network Structure Learning Algorithm". Machine Learning, 65(1), 31-78.

Examples

1
2
3
4
5
6
7
data(learning.test)

e1 = model2network("[A][B][C|A:B][D|B][E|C][F|A:E]")
e2 = model2network("[A][B][C|A:B][D|B][E|C:F][F|A]")
shd(e2, e1, debug = TRUE)
unlist(compare(e1,e2))
compare(target = e1, current = e2, arcs = TRUE)

vspinu/bnlearn documentation built on May 3, 2019, 7:08 p.m.