criteria.calculator {forestRK}R Documentation

Calculates Entropy or Gini Index of a particular node before (or without) a split

Description

Calculates the Entropy or Gini Index of a particular node before (or without) a split. This function is used inside the criteria.after.split.calculator method.

Usage

 criteria.calculator(x.node = data.frame(), y.new.node = c(),
                     entropy = TRUE)

Arguments

x.node

numericized data frame of covariates of a particular node (can be obtained by applying x.organizer) before or without a split; x.node should contain no NA or NaN's.

y.new.node

numericized vector of class type (y) of a particular node (can be obtained by applying y.organizer) before or without split; y.new.node should contain no NA or NaN's.

entropy

TRUE if Entropy is used as the splitting criteria; FALSE if Gini Index is used as the splitting criteria. Default is set to TRUE.

Value

A list containing the following items:

criteria

the value of the Entropy or the Gini Index of a particular node.

ent.status

logical value (TRUE or FALSE) of the parameter entropy.

Author(s)

Hyunjin Cho, h56cho@uwaterloo.ca Rebecca Su, y57su@uwaterloo.ca

See Also

criteria.after.split.calculator

Examples

 ## example: iris dataset
 library(forestRK) # load the package forestRK

 # covariates of training data set
 x.train <- x.organizer(iris[,1:4], encoding = "num")[c(1:25,51:75,101:125),]
 # numericized class types of observations of training dataset
 y.train <- y.organizer(iris[c(1:25,51:75,101:125),5])$y.new

 ## criteria.calculator() example
 ## calculate the Entropy of the original training dataset
 criteria.calculator(x.node = x.train, y.new.node = y.train)
 ## calculate the Gini Index of the original training dataset
 criteria.calculator(x.node = x.train, y.new.node = y.train, entropy = FALSE)

[Package forestRK version 0.0-5 Index]