Predicts each test observation's response using the random forest and, for each test observation and tree, finds the terminal node of the tree in which the test observation falls.
findTestPreds(forest, X.test, n.cores = 1)
The random forest object being used for prediction.
A matrix
or data.frame
with the observations to
be predicted. Each row should be an observation, and each column should be
a predictor variable.
Number of cores to use (for parallel computation in ranger
).
A data.table
with the following four columns:
The row ID of the test observation as provided by X.test
The random forest prediction of the test observation
The ID of the tree of the random forest
The ID of the terminal node of the tree in which the test observation falls
This function accepts regression random forests built using the randomForest
,
ranger
, randomForestSRC
, and quantregForest
packages.