ends.index.finder {forestRK}R Documentation

Identifies numerical indices of the end nodes of a rktree from the matrix of hierarchical flags.

Description

Identifies numerical indices of the end nodes of a rktree by closely examining the structure of the rktree flag (obtained via construct.treeRK()$flag); the precise algorithm used is the following:

if m-th string in the list of rktree flag is a substring of one or more of (m + 1),...,n-th strings in the list of flag, then the node represented by the m-th string of the flag is not an end node; otherwise, the node represented by the m-th string of the flag is the end node.

Usage

 ends.index.finder(tr.flag = matrix())

Arguments

tr.flag

a construct.treeRK()$flag object or a similar flag matrix.

Value

A vector that lists the indices of the end nodes of a given rktree (indices that are consistent to the indices in x.node.list, y.new.node.list, and flag that are returned by the construct.treeRK function).

Author(s)

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

See Also

construct.treeRK

Examples

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

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

  # Construct a tree
  # min.num.obs.end.node.tree is set to 5 by default;
  # entropy is set to TRUE by default
  tree.entropy <- construct.treeRK(x.train, y.train)

  # Find indices of end nodes of tree.entropy
  end.node.index <- ends.index.finder(tree.entropy$flag)

[Package forestRK version 0.0-5 Index]