Reputation: 21
I'm trying to compute the misclassification error on my data for the bagging classifier. I've done it successfully for two other sets of data by doing it this way:
mydata.bagging <- bagging(V5~., data=mydata, mfinal=10)
mydata.bagging.pred <- predict.bagging(mydata.bagging,newdata=mydata)
mydata.bagging.pred$confusion
mydata.bagging.pred$error
And it's worked perfectly fine. However, when I try to do the same thing with my third data, I get an error message that says
#Error in cbind(yval2, yprob, nodeprob) : number of rows of matrices must match (see arg 2)
I'm assuming this is because the third data has fewer rows than the other 2, but how would I be able to fix this problem and find the misclassification error?
Upvotes: 2
Views: 5131
Reputation: 21
I had similar problem and then figured it out.
It is possible that all of your left-hand side values (V5) are the same. The error is thrown as a saying that no decision can be made as it is too easy.
My source: http://kleinfelter.com/learning-r-painful-r-learnings
Upvotes: 2
Reputation: 51
After removing all 'NA', the problem has gone. Also, the first column has to be index column.
Upvotes: 0