[R] Tr: Re: how to pass weka classifier options with a meta classifier in RWeka?

Milan Bouchet-Valat nalimilan at club-internet.fr
Thu Feb 9 14:52:50 CET 2012

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
                            S=list("weka.attributeSelection.BestFirst, D=1),
                            W=list("weka.classifiers.bayes.NaiveBayes", D=1)))


More information about the R-help mailing list