[R] RWeka: how to pass arguments to BayesNet for specific search method

Valentin Kuznetsov vkuznet at gmail.com
Thu Jun 19 03:02:45 CEST 2014


Hi,

I'm trying to solve simple problem. How to pass arguments to specific search
method in RWeka package using BayesNet classifier. Here is code example:

BNet <- make_Weka_classifier("weka/classifiers/bayes/BayesNet")
K2="weka.classifiers.bayes.net.search.local.K2"
wcontrol <- Weka_control(D=TRUE,Q=list(K2,P=2))
model <- BNet(target~., data=train.df, control=wcontrol)

if I run this code it will complain

Error in .jcall(classifier, "V", "buildClassifier", instances) :
java.lang.Exception: Can't find class called: weka.classifiers.bayes.net.search.local.K2 -P 2
Calls: BNet ... RWeka_build_classifier -> .jcall -> .jcheck -> .Call

I know that arguments can be passed via Weka_control, and it works if I just
use search method, e.g.

wcontrol <- Weka_control(D=T,Q=K2)

and here D=T option works too.

What it should do is to pass additional -- after K2 class.
According to http://www.cs.waikato.ac.nz/~remco/weka.bn.pdf and
using java command it should looks like this:

java weka.classifiers.bayes.BayesNet -t iris.arff -D -Q weka.classifiers.bayes.net.search.local.K2 -- -P 2

I tried to append double dash to K2 definition, e.g.

K2="weka.classifiers.bayes.net.search.local.K2 --"

but still out of luck.

Any suggestions?

Thanks,
Valentin.



More information about the R-help mailing list