score {bnlearn} | R Documentation |
Compute the score of the Bayesian network.
score(x, data, type = "dir", debug = FALSE) ## S3 method for class 'bn': logLik(object, data, ...) ## S3 method for class 'bn': AIC(object, data, ..., k = 1)
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 Criterion aka BIC) and dir
(Bayesian Dirichlet aka BDe). |
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. |
A numeric value, the score of the Bayesian network.
Only discrete Bayesian networks are supported.
The execution time scales linearly with the sample size.
Marco Scutari
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.
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