Extracts for each observation and for each tree in the forest the terminal node id.
terminalNodeIDs(x, rfObject)
a data.frame
ranger object
ranger
Matrix with terminal node IDs for all observations in x (rows) and trees (columns)
# NOT RUN { library(ranger) rf.fit <- ranger(Species ~ ., data = iris, num.trees = 5, write.forest = TRUE) dfNodes <- terminalNodeIDs(iris[, -5], rf.fit) # }
Run the code above in your browser using DataLab