How to calculate accuracy of a decision tree using rpart in R

rpart

#1

Hello,

I am having a dataset which has responses to various questions recorded.Some of the records have no response/missing values recorded as 0.For example a sample ques has the distribution.

table(vodka$Q13)

  0   1   2   3   4 
 96 750 232  69  17 

0 is quite high here(96 out of 1164) records.So I was thinking of using decision trees to predict the value for records which have this value as 0.This is my code:

loantime.train <- vodka[which(vodka$Q13 != 0),]
loantime.test <- vodka[which(vodka$Q13 == 0),]
library(rpart)
loantime.rpart <- rpart(Q13 ~ .,data = loantime.train,method = "class")
printcp(loantime.rpart)

The output:

Can I say that the accuracy is 1-0.29775 or is there some other parameter which can be used for that.
How are such cases really dealt with ?
Can someone please help me with this??


#2

Hi,

no this is not the accuracy measure.
The xerror * the root node error gives the error (on the cross validation), in your case with pruning you have .29775 * 1.0377.
Alain