nezezime / bnAnomaly

Anomaly Detection With Bayesian Networks
1 stars 0 forks source link

Error in rcpp_init_node #3

Open cosmin-novac opened 3 years ago

cosmin-novac commented 3 years ago

Hi there,

I'm using this together with bnlearn, and I'm receiving the following error:

Error in rcpp_init_node(as.data.frame(dnode$prob), dnode_name, dnode_parents,  : 
  Not compatible with STRSXP: [type=NULL].

Upon further investigation, I found out that 1) there are two types of nodes, dnodes and cgnodes. The latter are empty, but the loop in cpp.init still attempts to take them into consideration. Is this correct? 2) rcpp_init_node doesn't accept the probabilities in dnode$prob: "Input probability table contains zero probabilities"

cosmin-novac commented 3 years ago

I fixed this by adding the following lines to cpp.init:

        if(class(dnode)=="bn.fit.cgnode") next;
        probs <- as.data.frame(dnode$prob)
        probs[probs == 0] <- 1e-50

But now the next step doesn't run:

cpp_logLik(bn_data)
Error in cpp_logLik(bn_data) : _Map_base::at