Learn R Programming

gamclass (version 0.62.5)

rpartErr: Calculate Error Rates for rpart model

Description

Given an rpart model object, calculate training set error, 10-fold cross-validation error, and test set error.

Usage

rpartErr(train.rp, train, test, group = "type")

Value

Vector that holds training set error, 10-fold cross-validation error, and test set error rates.

Arguments

train.rp

Fitted lda model object.

train

Training set data frame.

test

Test set data frame.

group

Factor that identifies groups

Examples

Run this code
if (FALSE) {
data(spam, package='kernlab')
spam[,-58] <- scale(spam[,-58])
nr <- sample(1:nrow(spam))
spam01 <- spam[nr[1:3601],]     ## Use for training,
## if holdout not needed
spam2 <- spam[nr[3602:4601],]   ## Test
spam01.rp <- rpart(type~., data=spam01, cp=0.0001)
rpRates <- rpartErr(train.rp=spam01.rp, train=spam01, test=spam2,
                    group='type')
}

Run the code above in your browser using DataLab