rbnlearn

How to use custom score functions in bnlearn version 4.6?


bnlearn 4.6 has support for custom decomposable scores according to the changelog. I can't figure out how to use it though. I've tried net <- hc(df, score = "custom") and it gives me Error in check.custom.score.function(fun = extra.args$fun): missing the custom score function. Anyone know how to feed the custom function to hc?


Solution

  • Figured it out from bnlearn:::check.score.args. You need to provide a fun argument, so something like net <- hc(df, score = "custom", fun=function(...) ...). Just for reference, the function signature is function(node, parents, data, args).