checkForestUnanimity: Check the unanimity of all trees in the Random Forest model

Description Usage Arguments Value Author(s) See Also Examples

Description

This method checks the unanimity of all individual trees in the forest for classification models: this denotes the condition that, for any given leaf (i.e. terminal) node of the tree, all instances in the training set assigned to that node should belong to a single class. If this holds for a single tree, the tree is considered unanimous. Only if this condition -i.e. that all trees are unanimous - holds will the predictions obtained (for "class 1") for a binary classification model using predict(...,type="prob") and predictBC(...) be the same.

Usage

1
checkForestUnanimity(object, dataT)

Arguments

object

an object of the class randomForest

dataT

a data frame with columns containing the attributes (descriptors) for all instances (rows) in the training set of the randomForest object

Value

A list with the following components:

dec

TRUE if all trees in the forest are unanimous, otherwise FALSE

tcCount

a list providing the number of training set instances in each class for each terminal node in all trees. Where the number 0 is presented for all classes, the corresponding node is not a terminal node.

tuStatus

a vector, with one element per tree, denoting whether or not that tree was unanimous (TRUE) or not (FALSE)

Author(s)

Anna Palczewska annawojak@gmail.com

See Also

randomForest

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#Iris dataset
library(randomForest)
data(iris)
rF_Model <- randomForest(x=iris[,-5],y=as.factor(as.character(iris[,5])), 
                              ntree=10,importance=TRUE, keep.inbag=TRUE,replace=FALSE)

#Check unanimity
itest<-checkForestUnanimity(rF_Model, iris[,-5])



## Not run: 
# Ames dataset
data(ames)
ames_train<-ames[ames$Type=="Train",-c(1,3, ncol(ames))]
rF_Model <- randomForest(x=ames_train[,-1],y=as.factor(as.character(ames_train[,1])), 
                                ntree=500,importance=TRUE, keep.inbag=TRUE,replace=FALSE)
itest<-checkForestUnanimity(rF_Model, ames_train[,-1])

## End(Not run)

rfFC documentation built on May 2, 2019, 5:18 p.m.