CV in random forest: is 0


While trying to do cross validation in R: I am getting =0

rfcvtest <- rfcv(traindata, traindata$Ind ,cv.fold = 5)

Any help is appreciated.



Hi Soumya,

Please take a look at the code below:

rf <-rfcv(iris, iris$Species, cv.fold=5)
#Capture the error rates:
rf.error <- rf$
#Take the predicted values at each fold: <- rf$predicted$`1`
#Compare with original data:
table(iris$Species, <- rf$predicted$`2`
table(iris$Species, <- rf$predicted$`5`

The outputs:

As you can see in the first output for cv = 2 the number of miss-classified cases is just 7 out of 150 which gives an error rate of 0.0467,whereas if you take a look at the last output,all the classes have been correctly classified and that is why the is coming out to be zero.
the is a vector that captures the error rate at each step.
I beleive in your case the accuracy is 100% when cv.folds = 5.
Hope this helps!!


Thanks Shuvayan for the explanation.
I had not checked for confusion matrix at each step. Indeed the classes seems to be correctly classified at each step.