query.rf.pred.idx {RfEmpImp}R Documentation

Identify corresponding observations indexes under the terminal nodes for a random forest model by ranger

Description

The observation indexes (row numbers) constituting the terminal node associated with each observation are queried using the ranger object and the training data. The parameter keep.inbag = TRUE should be applied to call to ranger.

Usage

query.rf.pred.idx(obj, data, id.name = FALSE, unique.by.id = FALSE, ...)

Arguments

obj

An R object of class ranger.

data

Input for training data.

id.name

Use the IDs of the terminal nodes as names for the lists.

unique.by.id

Only return results of unique terminal node IDs.

...

Other parameters (will be ignored).

Details

The observations are found based on terminal node IDs. It should be noted that the out-of-bag observations are not present in the indexes.

Value

A nested list of length num.trees.

Author(s)

Shangzhi Hong

Examples

data(iris)
rfObj <- ranger(
    Sepal.Length ~ Sepal.Width + Petal.Length + Petal.Width + Species,
    data = iris, num.trees = 5, keep.inbag = TRUE)
outList <- query.rf.pred.idx(rfObj, iris)


[Package RfEmpImp version 2.1.8 Index]