Does anyone know how to calculate the error rate for a decision tree with R?
I am using the rpart() function.
Does anyone know how to calculate the error rate for a decision tree with
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming you mean computing error rate on the sample used to fit the model, you can use
printcp(). For example, using the on-line example,The
Root node erroris used to compute two measures of predictive performance, when considering values displayed in therel errorandxerrorcolumn, and depending on the complexity parameter (first column):0.76471 x 0.20988 = 0.1604973 (16.0%) is the resubstitution error rate (i.e., error rate computed on the training sample) — this is roughly
0.82353 x 0.20988 = 0.1728425 (17.2%) is the cross-validated error rate (using 10-fold CV, see
xvalinrpart.control(); but see alsoxpred.rpart()andplotcp()which relies on this kind of measure). This measure is a more objective indicator of predictive accuracy.Note that it is more or less in agreement with classification accuracy from
tree:where
Misclassification error rateis computed from the training sample.