| tidyRF {tree.interpreter} | R Documentation |
Tidy Random Forest
Description
Converts random forest objects from various libraries into a common
structure, i.e. a “tidy” random forest, calculating absent auxiliary
information on demand, in order to provide a uniform interface for other
tree.interpreter functions. Note that the output is of a private
format, and is subject to change.
Usage
tidyRF(rfobj, trainX, trainY)
Arguments
rfobj |
A random forest object. Currently, supported libraries include
|
trainX |
A data frame. Train set features. |
trainY |
A data frame. Train set responses. |
Value
A list of class tidyRF, with entries:
num.treesAn integer. Number of trees.
feature.namesA vector. Names of features.
num.classesAn integer. For classification trees, number of classes of the response. For regression trees, this field will always be 1.
class.namesA vector. Names of response classes.
inbag.countsA list. For each tree, a vector of the number of times the observations are in-bag in the trees.
left.childrenA list. For each tree, a vector of the left children of its nodes.
right.childrenA list. For each tree, a vector of the right children of its nodes.
split.featuresA list. For each tree, a vector of the indices of features used at its nodes. Indices start from 0. A value of 0 means the node is terminal. This does not cause ambiguity, because the root node will never be a child of other nodes.
split.valuesA list. For each tree, a vector of the values of features used at its nodes.
node.sizesA list. For each tree, a vector of the sizes of its nodes.
node.respA list. For each tree, a vector of the responses of its nodes.
delta.node.resp.leftA list. For each tree, a vector of the difference between the responses of the left children of its nodes and themselves.
delta.node.resp.rightA list. For each tree, a vector of the difference between the responses of the right children of its nodes and themselves.
Examples
library(ranger)
rfobj <- ranger(Species ~ ., iris, keep.inbag=TRUE)
tidy.RF <- tidyRF(rfobj, iris[, -5], iris[, 5])
str(tidy.RF, max.level=1)