Learn R Programming

bnlearn (version 0.5)

score: Score of the Bayesian network

Description

Compute the score of the Bayesian network.

Usage

score(x, data, type = "bde", debug = FALSE)

## S3 method for class 'bn': logLik(object, data, ...) ## S3 method for class 'bn': AIC(object, data, ..., k = 1)

Arguments

x
an object of class "bn".
object
an object of class "bn".
data
a data frame, containing the data the Bayesian network was learned from.
type
a character string, the label of the score. Valid values are lik (likelihood), loglik (log-likelihood), aic (Akaike Information Criterion aka AIC), bic (Bayesian Information Crite
debug
a boolean value. If TRUE a lot of debugging output is printed; otherwise the function is completely silent.
...
extra arguments from the generic method (currently ignored).
k
a numeric value, the penalty per parameter to be used; the default k = 1 gives the expression used to compute the AIC in the context of scoring Bayesian networks.

Value

  • A numeric value, the score of the Bayesian network.

References

D. M. Chickering. A Transformational Characterization of Equivalent Bayesian Network Structures. In Proceedins of 11th Conference on Uncertainty in Artificial Intelligence, pages 87-98. Morgan Kaufmann Publishers Inc., 1995.

Examples

Run this code
data(learning.test)
res = set.arc(gs(learning.test), "A", "B")
score(res, learning.test, type = "dir")
# [1] -25005.24
# let's see score equivalence in action!
res = set.arc(gs(learning.test), "B", "A")
score(res, learning.test, type = "dir")
# [1] -25005.24

# equivalent to logLik(res, learning.test)
score(res, learning.test, type = "loglik")
# [1] -129.9684

# equivalent to AIC(res, learning.test)
score(res, learning.test, type = "aic")
# [1] -170.9684

Run the code above in your browser using DataLab