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.trees
An integer. Number of trees.
feature.names
A vector. Names of features.
num.classes
An integer. For classification trees, number of classes of the response. For regression trees, this field will always be 1.
class.names
A vector. Names of response classes.
inbag.counts
A list. For each tree, a vector of the number of times the observations are in-bag in the trees.
left.children
A list. For each tree, a vector of the left children of its nodes.
right.children
A list. For each tree, a vector of the right children of its nodes.
split.features
A 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.values
A list. For each tree, a vector of the values of features used at its nodes.
node.sizes
A list. For each tree, a vector of the sizes of its nodes.
node.resp
A list. For each tree, a vector of the responses of its nodes.
delta.node.resp.left
A list. For each tree, a vector of the difference between the responses of the left children of its nodes and themselves.
delta.node.resp.right
A 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)