Extracts tree information from a ocf.forest object.

tree_info(object, tree = 1)

Arguments

object

ocf.forest object.

tree

Number of the tree of interest.

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.

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.

References

  • Di Francesco, R. (2023). Ordered Correlation Forest. arXiv preprint arXiv:2309.08755.

See also

Author

Riccardo Di Francesco

Examples

## Generate synthetic data.
set.seed(1986)

data <- generate_ordered_data(1000)
sample <- data$sample
Y <- sample$Y
X <- sample[, -1]

## Fit ocf.
forests <- ocf(Y, X)

## Extract information from tenth tree of first forest.
info <- tree_info(forests$forests.info$forest.1, tree = 10)
head(info)
#>   nodeID leftChild rightChild splitvarID   splitval terminal prediction
#> 1      0         1          2          0 -0.4391133    FALSE         NA
#> 2      1         3          4          2  1.7669168    FALSE         NA
#> 3      2         5          6          0  0.9056179    FALSE         NA
#> 4      3         7          8          0 -1.2427746    FALSE         NA
#> 5      4        NA         NA         NA         NA     TRUE          0
#> 6      5         9         10          3  0.5000000    FALSE         NA