rfErr function

Calculate Error Rates for randomForest model

Calculate Error Rates for randomForest model

Given an randomForest model object, calculate training set error, out-of-bag (OOB) error, and test set error.

rfErr(train.rf, train, test, group = "type")

Arguments

  • train.rf: Fitted randomForest model object.
  • train: Training set data frame.
  • test: Test set data frame.
  • group: Factor that identifies groups

Returns

Vector that holds training set error, out-of-bag (OOB) error, and test set error rates.

Examples

## Not run: data(spam, package='kernlab') spam[,-58] <- scale(spam[,-58]) nr <- sample(1:nrow(spam)) spam01 <- spam[nr[1:3601],] ## Use for training, spam2 <- spam[nr[3602:4601],] ## Test spam01.rf <- randomForest(type ~ ., data=spam01) rfRates <- rfErr(train.rf=spam01.rf, train=spam01, test=spam2, group='type') ## End(Not run)
  • Maintainer: John Maindonald
  • License: GPL (>= 2)
  • Last published: 2023-08-21

Useful links