Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7619725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:45:35+00:00 2026-05-31T03:45:35+00:00

Does anyone know how to calculate the error rate for a decision tree with

  • 0

Does anyone know how to calculate the error rate for a decision tree with R?
I am using the rpart() function.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T03:45:36+00:00Added an answer on May 31, 2026 at 3:45 am

    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,

    > library(rpart)
    > fit <- rpart(Kyphosis ~ Age + Number + Start, data=kyphosis)
    > printcp(fit)
    
    Classification tree:
    rpart(formula = Kyphosis ~ Age + Number + Start, data = kyphosis)
    
    Variables actually used in tree construction:
    [1] Age   Start
    
    Root node error: 17/81 = 0.20988
    
    n= 81 
    
            CP nsplit rel error  xerror    xstd
    1 0.176471      0   1.00000 1.00000 0.21559
    2 0.019608      1   0.82353 0.82353 0.20018
    3 0.010000      4   0.76471 0.82353 0.20018
    

    The Root node error is used to compute two measures of predictive performance, when considering values displayed in the rel error and xerror column, 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

      class.pred <- table(predict(fit, type="class"), kyphosis$Kyphosis)
      1-sum(diag(class.pred))/sum(class.pred)
      
    • 0.82353 x 0.20988 = 0.1728425 (17.2%) is the cross-validated error rate (using 10-fold CV, see xval in rpart.control(); but see also xpred.rpart() and plotcp() 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:

    > library(tree)
    > summary(tree(Kyphosis ~ Age + Number + Start, data=kyphosis))
    
    Classification tree:
    tree(formula = Kyphosis ~ Age + Number + Start, data = kyphosis)
    Number of terminal nodes:  10 
    Residual mean deviance:  0.5809 = 41.24 / 71 
    Misclassification error rate: 0.1235 = 10 / 81 
    

    where Misclassification error rate is computed from the training sample.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know how to calculate the error of quantizing from 16bit to 8bit?
Does anyone know how to calculate the complexity of a nested binary search tree?
Does anyone know how to calculate time difference in C++ in milliseconds? I used
Does anyone know how to calculate the area in common between 2 or more
Maths101 question - does anyone know how to calculate an ellipse (width/height) that will
Does anyone know of existing software or algorithms to calculate a package size for
Does anyone know of a good way to calculate the semantic distance between two
Does anyone know how can I calculate pi (π) in VB?
How can I calculate the logarithm of a BigDecimal? Does anyone know of any
Does anyone know how exactly the asset digest value is calculated? If I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.