Milan Bouchet-Valat
2012-Feb-09 13:52 UTC
[R] Tr: Re: how to pass weka classifier options with a meta classifier in RWeka?
Le jeudi 09 f?vrier 2012 ? 15:31 +0200, Kari Ruohonen a ?crit :> Hi, > I am trying to replicate a training of AttributeSelectedClassifier with > CFsSubsetEval, BestFirst and NaiveBayes that I have initially done with > Weka. Now, I am trying to use RWeka in R. > > I have a problem of passing arguments to the CfsSubsetEval, BestFirst > and NaiveBayes. I have first created an interface for the classifier > with: > > AS<-make_Weka_classifier("weka/classifiers/meta/AttributeSelectedClassifier") > > And then I am trying to run the classifier with: > > nb.model<-AS(class~.,data=ex, > ? ? ? ? ?control=Weka_control( > ? ? ? ? ? ?E="weka.attributeSelection.CfsSubsetEval", > ? ? ? ? ? ?S="weka.attributeSelection.BestFirst -D 1", > ? ? ? ? ? ?W="weka.classifiers.bayes.NaiveBayes -D")) > > But now, I get an error saying: > > Error in .jcall(classifier, "V", "buildClassifier", instances) : > ? java.lang.Exception: Can't find class called: > weka.classifiers.bayes.NaiveBayes -D > > indicating that the way I am passing the argument "-D" to the NaiveBayes > is incorrect. I am uncertain from the RWeka documentation how the > passing mechanism of Weka_control is supposed to work with meta > classifiers. All help is greatly appreciated.I've never tried it myself, but ?Weka_control says: ? ? One can use lists for options taking multiple arguments, see the ? ? documentation for ?SMO? for an example. So maybe nb.model<-AS(class~.,data=ex, ? ? ? ? ? ? ? ? ? ? ? ? ? control=Weka_control( ? ? ? ? ? ? ? ? ? ? ? ? ? ?E="weka.attributeSelection.CfsSubsetEval", ? ? ? ? ? ? ? ? ? ? ? ? ? ?S=list("weka.attributeSelection.BestFirst, D=1), ? ? ? ? ? ? ? ? ? ? ? ? ? ?W=list("weka.classifiers.bayes.NaiveBayes", D=1))) Cheers
Kari Ruohonen
2012-Feb-09 13:57 UTC
[R] Tr: Re: how to pass weka classifier options with a meta classifier in RWeka?
On Thu, 2012-02-09 at 14:52 +0100, Milan Bouchet-Valat wrote:> Le jeudi 09 f?vrier 2012 ? 15:31 +0200, Kari Ruohonen a ?crit :<snip>> > > > And then I am trying to run the classifier with: > > > > nb.model<-AS(class~.,data=ex, > > control=Weka_control( > > E="weka.attributeSelection.CfsSubsetEval", > > S="weka.attributeSelection.BestFirst -D 1", > > W="weka.classifiers.bayes.NaiveBayes -D")) > > > > But now, I get an error saying: > > > > Error in .jcall(classifier, "V", "buildClassifier", instances) : > > java.lang.Exception: Can't find class called: > > weka.classifiers.bayes.NaiveBayes -D > > > > indicating that the way I am passing the argument "-D" to the NaiveBayes > > is incorrect. I am uncertain from the RWeka documentation how the > > passing mechanism of Weka_control is supposed to work with meta > > classifiers. All help is greatly appreciated. > I've never tried it myself, but ?Weka_control says: > One can use lists for options taking multiple arguments, see the > documentation for ?SMO? for an example. > > So maybe > nb.model<-AS(class~.,data=ex, > control=Weka_control( > E="weka.attributeSelection.CfsSubsetEval", > S=list("weka.attributeSelection.BestFirst, D=1), > W=list("weka.classifiers.bayes.NaiveBayes", D=1))) > > > CheersHi and thanks for the suggestion. Unfortunately, it results in a similar error: Error in .jcall(classifier, "V", "buildClassifier", instances) : java.lang.Exception: Can't find class called: weka.classifiers.bayes.NaiveBayes -D 1 regards, Kari