R bnlearn - parameter learning with naive.bayes() check.data() error -


i have graph structure, determined method, , want parameter learning. bnlearn methods, however, seem parameter learning directly on dataset (strictly in dataframe). have 2 questions: how do parameter learning igraph or graphnel structure bnlearn?

second question: getting check.data() error when try parameter learning using dataset. example code works, , can't understand why dataset not. see code below , reproducible example, below.

here example code:

require(bnlearn) require(rgraphviz) data(learning.test) bn <- naive.bayes(learning.test, "a") pred <- predict(bn, learning.test) table(pred, learning.test[,"a"]) 

my reproducible example (errors on naive.bayes() call):

require(bnlearn, rgraphviz) data <- data <- matrix(sample.int(200, 61*252, true), nrow=252, ncol=61) data <- as.data.frame(matrix(as.numeric(as.matrix(data)), ncol=ncol(data),          byrow=true)) bn <- naive.bayes(data, names(data)[1]) 

error message:

error in check.data(data, allowed.types = discrete.data.types) :  valid data types are: * variables must unordered factors. * variables must ordered factors. * variables can either ordered or unordered factors. 

i not think error comes detecting integers, because when cast data dataframe, first cast numeric, because other methods in bnlearn require numeric or factored data. dataset count data, want use method assuming using continuous datasets. make sense?


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -