[R] RWeka prediction

Achim Zeileis Achim.Zeileis at wu-wien.ac.at
Sun Apr 26 11:45:21 CEST 2009


On Sun, 26 Apr 2009, Dajiang Liu wrote:

> Dear All,I encountered a problem when I use RWeka for prediction.
> Specifically, I use the following:
>
> res=J48(X1~.,data=mydata);
> predict(res), #it worked fine
>
> but when I tried to use a different data set,
>
> i.e. predict(res,newdata=mynewdata);
> all the predictions I get is 0, which apparently is problematic.
>
> What is weird is, if I use the old data, but use the newdata option,
> i.e.
>
> predict(res,newdata=mydata), all prediction is 0;
>
> Can anyone hint me what is wrong?

No, because you do not provide sufficient information (as requested by the 
posting guide pointed to below). For me, this works fine:

library("RWeka")
ldat <- iris[1:140,]
tdat <- iris[-(1:140),]
m <- J48(Species ~ ., data = ldat)
predict(m, newdata = tdat)


> Thanks a lot.
> Regards,
> Dajiang
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>
>




More information about the R-help mailing list