terminalNodes {CaseBasedReasoning}R Documentation

Get the terminal node id of a RandomForest Object

Description

Extracts for each observation and for each tree in the forest the terminal node id. The index of terminal nodes are starting with 1, e.g., the root node has id 1

Usage

terminalNodes(x, rfObject)

Arguments

x

a data.frame

rfObject

ranger object

Value

Matrix with terminal node IDs for all observations in x (rows) and trees (columns)

Examples

library(ranger)
rf.fit <- ranger(Species ~ ., data = iris, num.trees = 5, write.forest = TRUE)
dfNodes <- terminalNodes(iris[, -5], rf.fit)


[Package CaseBasedReasoning version 0.3 Index]