Functions coercing various forest objects to objects of class “stabletree”.
Usage
as.stabletree(x, ...)
## S3 method for class 'randomForest'
as.stabletree(x, applyfun = NULL, cores = NULL, ...)
## S3 method for class 'RandomForest'
as.stabletree(x, applyfun = NULL, cores = NULL, ...)
## S3 method for class 'cforest'
as.stabletree(x, applyfun = NULL, cores = NULL, savetrees = FALSE, ...)
## S3 method for class 'ranger'
as.stabletree(x, applyfun = NULL, cores = NULL, ...)
Arguments
x
an object of class randomForest, RandomForest-class, cforest, or ranger.
applyfun
a lapply-like function. The default is to use lapply unless cores is specified in which case mclapply is used (for multicore computations on platforms that support these).
cores
integer. The number of cores to use in multicore computations using mclapply (see above).
savetrees
logical. If TRUE, trees of the forests are returned.
…
additional arguments (currently not used).
Details
Random forests fitted using randomForest, cforest, cforest or ranger are coerced to “stabletree” objects.
Note that when plotting a randomForest or ranger, the gray areas of levels of a nominal variable do not mimic exactly the same behavior as for classical “stabletree” objects, due to randomForest and ranger, not storing any information whether any individuals were left fulfilling the splitting criterion in the subsample. Therefore, gray areas only indicate that this level of this variable has already been used in a split before in such a way that it could not be used for any further splits.
For ranger, interaction terms are (currently) not supported.
Value
as.stabletree returns an object of class “stabletree” which is a list with the following components:
call
the call from the model object x,
B
the number of trees of the random forest,
sampler
the random forest fitting function,
vs0
numeric vector of the variable selections of the original tree, here always a vector of zeros because there is no original tree,
br0
always NULL (only included for consistency),
vs
numeric matrix of the variable selections for each tree of the random forest,
br
list of the break points (only the breaks for each variable over all trees of the random forest,
classes
character vector indicating the classes of all partitioning variables,
Call:
A ModelEnvFormula with
response variable(s): Species
input variable(s): Sepal.Length Sepal.Width Petal.Length Petal.Width
number of observations: 150
Sampler:
B = 500
Method = party::cforest