[R] RWeka: how to pass arguments to BayesNet for specific search method
p_connolly at slingshot.co.nz
Thu Jun 19 06:28:24 CEST 2014
My suggestion is not entirely satisfactory, but it's got me out
of a few jams.
When I can't get the RWeka syntax to work, I resort to using
direct weka code in a system call. One such example looks like
this and will make sense if you know how Weka does things.
system("java weka.classifiers.bayes.NaiveBayes -t HWlrTrain.arff -T
HWlrTest.arff -o -threshold-file Threshold.arff")
thresholdNB.df <- read.arff("Threshold.arff")
I know it kind of defeats the purpose somewhat. But it is making
use of RWeka's ability to make arff files which is quite useful
On 2014-06-19 13:02, Valentin Kuznetsov wrote:
> I'm trying to solve simple problem. How to pass arguments to specific
> method in RWeka package using BayesNet classifier. Here is code
> BNet <- make_Weka_classifier("weka/classifiers/bayes/BayesNet")
> 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
> 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?
> R-help at r-project.org mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help