Learn R Programming

rerf (version 2.0.4)

PrintTree: RerF Tree Printer

Description

Prints the layout of a specified tree.

Usage

PrintTree(forest, numTree = 1, pretty = FALSE)

Arguments

forest

a rerf forest structure.

numTree

the tree number to print. (numTree=1)

pretty

boolean if TRUE the column of cut features are formatted nicely for viewing. (FALSE)

Value

a data.frame with the following information about the tree:

  • nodeNum The node number

  • LC The id of the left child of the node

  • RC The id of the right child of the node

  • CutValue The cut value of non-terminal nodes, otherwise NA.

  • nodeClass The class vote of a terminal node when used for classification/prediction.

  • CutFeatures a list of ordered pairs \((d, w)\), where d is the original feature and w is the corresponding weight.

Examples

Run this code
# NOT RUN {
### Train RerF on numeric data ###
library(rerf)
numTree <- 1
forest <- RerF(as.matrix(iris[, 1:4]), iris[, 5], num.core = 1L)
forest.rmc <- RerF(as.matrix(iris[, 1:4]), iris[, 5], num.core = 1L, RandMatContinuous)
(out <- PrintTree(forest, numTree))
(out.rmc <- PrintTree(forest.rmc, numTree))

# }

Run the code above in your browser using DataLab