Learn R Programming

morf (version 1.0.0)

tree_info: Tree Information in Readable Format

Description

Extracts tree information from a morf.forest object.

Usage

tree_info(object, tree = 1)

Value

A data.frame with the following columns:

nodeID

Node IDs.

leftChild

IDs of the left child node.

rightChild

IDs of the right child node.

splitvarID

IDs of the splitting variable.

splitvarName

Name of the splitting variable.

splitval

Splitting value.

terminal

Logical, TRUE for terminal nodes.

prediction

One column with the predicted conditional class probabilities.

Arguments

object

morf.forest object.

tree

Number of the tree of interest.

Author

Riccardo Di Francesco

Details

Nodes and variables IDs are 0-indexed, i.e., node 0 is the root node.

All values smaller than or equal to splitval go to the left and all values larger go to the right.

See Also

morf

Examples

Run this code
# \donttest{
## Load data from orf package.
set.seed(1986)

library(orf)
data(odata)
odata <- odata[1:200, ] # Subset to reduce elapsed time.

y <- as.numeric(odata[, 1])
X <- as.matrix(odata[, -1])

## Fit morf.
forests <- morf(y, X)

## Extract information from tenth tree of first forest.
info <- tree_info(forests$forests.info$forest.1, tree = 10)
head(info)# }
  

Run the code above in your browser using DataLab