On Wed, 3 Jun 2009, Huihua Lu wrote:

Hi everyone,

I have trouble to use RWeka, I tried: (w=weather dataset, all
preditors are nominal)

m<-J48(play~., data=w)
e<-evaluate_Weka_classifier(m,cost = matrix(c(0,2,1,0),
+ ncol = 2),numFolds = 10, complexity = TRUE,seed = 123,
+ class = TRUE)
it gives me exactly what I want, but when I tried the same classifier
on the other published data: (iris dataset has all numeric preditors)

m<-J48(Species~., data=iris)
e <- evaluate_Weka_classifier(m,
+ cost = matrix(c(0,2,1,0), ncol = 2),
+ numFolds = 10, complexity=TRUE, class=TRUE)
it threw me the error as below:

Error in .jnew("weka/classifiers/Evaluation", instances, costMatrix) :
 Failed to create object of class `weka/classifiers/Evaluation'
In addition: Warning message:
In .jnew("weka/classifiers/Evaluation", instances, costMatrix) :
 NewObject
("weka/classifiers/Evaluation","(Lweka/core/Instances;Lweka/classifiers
/CostMatrix;)V",...) failed

I know there are something wrong in the function of
evaluate_Weka_classifier, but I am stuck. Any one can help me out?
Is it because the attributes of predictors?  then, how can I set up
the parameters in evaluat_Weka_classifier function? Thanks very much!

For me, it throws one more error, that you didn't include:

Exception in thread "main" java.lang.Exception: Cost matrix not compatible with data!
        at weka.classifiers.Evaluation.<init>(Unknown Source)

Your response has three levels, hence the cost matrix needs to be 3x3.

e <- evaluate_Weka_classifier(m,
  cost = matrix(c(0, 1, 2, 2, 0, 1, 1, 1, 0), ncol = 3),
  numFolds = 10, complexity=TRUE, class=TRUE)

works correctly but throws a warning. This warning is not critical, though, and should be fixed in the next RWeka version.

Best,
Z

lu

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to