Prediction with new data and a saved forest from Ranger.
# S3 method for ranger predict(object, data = NULL, predict.all = FALSE, num.trees = object$num.trees, type = "response", se.method = "infjack", quantiles = c(0.1, 0.5, 0.9), seed = NULL, num.threads = NULL, verbose = TRUE, ...)
New test data of class
Return individual predictions for each tree instead of aggregated predictions for all trees. Return a matrix (sample x tree) for classification and regression, a 3d array for probability estimation (sample x class x tree) and survival (sample x time x tree).
Number of trees used for prediction. The first
num.trees in the forest are used.
Type of prediction. One of 'response', 'se', 'terminalNodes', 'quantiles' with default 'response'. See below for details.
Method to compute standard errors. One of 'jack', 'infjack' with default 'infjack'. Only applicable if type = 'se'. See below for details.
Vector of quantiles for quantile prediction. Set
type = 'quantiles' to use.
Random seed. Default is
NULL, which generates the seed from
R. Set to
0 to ignore the
R seed. The seed is used in case of ties in classification mode.
Number of threads. Default is number of CPUs available.
Verbose output on or off.
further arguments passed to or from other methods.
Object of class
ranger.prediction with elements
||Predicted classes/values (only for classification and regression)|
||Unique death times (only for survival).|
||Estimated cumulative hazard function for each sample (only for survival).|
||Estimated survival function for each sample (only for survival).|
||Number of trees.|
||Number of independent variables.|
||Type of forest/tree. Classification, regression or survival.|
type = 'response' (the default), the predicted classes (classification), predicted numeric values (regression), predicted probabilities (probability estimation) or survival probabilities (survival) are returned.
type = 'se', the standard error of the predictions are returned (regression only). The jackknife-after-bootstrap or infinitesimal jackknife for bagging is used to estimate the standard errors based on out-of-bag predictions. See Wager et al. (2014) for details.
type = 'terminalNodes', the IDs of the terminal node in each tree for each observation in the given dataset are returned.
type = 'quantiles', the selected quantiles for each observation are estimated. See Meinshausen (2006) for details.
type = 'se' is selected, the method to estimate the variances can be chosen with
se.method = 'jack' for jackknife-after-bootstrap and
se.method = 'infjack' for the infinitesimal jackknife for bagging.
For classification and
predict.all = TRUE, a factor levels are returned as numerics.
To retrieve the corresponding factor levels, use
rf is the ranger object.
Wright, M. N. & Ziegler, A. (2017). ranger: A Fast Implementation of Random Forests for High Dimensional Data in C++ and R. J Stat Softw 77:1-17. https://doi.org/10.18637/jss.v077.i01.
Wager, S., Hastie T., & Efron, B. (2014). Confidence Intervals for Random Forests: The Jackknife and the Infinitesimal Jackknife. J Mach Learn Res 15:1625-1651. http://jmlr.org/papers/v15/wager14a.html.
Meinshausen (2006). Quantile Regression Forests. J Mach Learn Res 7:983-999. http://www.jmlr.org/papers/v7/meinshausen06a.html.