Three steps variable selection procedure based on random forests for supervised classification and regression problems. First step ("thresholding step") is dedicated to eliminate irrelevant variables from the dataset. Second step ("interpretation step") aims to select all variables related to the response for interpretation purpose. Third step ("prediction step") refines the selection by eliminating redundancy in the set of variables selected by the second step, for prediction purpose.
VSURF(x, ...)# S3 method for default
VSURF(x, y, ntree = 2000,
mtry = max(floor(ncol(x)/3), 1), nfor.thres = 50, nmin = 1,
nfor.interp = 25, nsd = 1, nfor.pred = 25, nmj = 1,
RFimplem = "randomForest", parallel = FALSE, ncores = detectCores()
- 1, clusterType = "PSOCK", verbose = TRUE, ...)
# S3 method for formula
VSURF(formula, data, ..., na.action = na.fail)
An object of class VSURF
, which is a list with the following
components:
A vector of indexes of variables selected after "thresholding step", sorted according to their mean VI, in decreasing order.
A vector of indexes of variables selected after "interpretation step".
A vector of indexes of variables selected after "prediction step".
A vector of the 3 numbers of variables selected resp. by "thresholding step", "interpretation step" and "prediction step".
A vector of importance of the
varselect.thres
variables.
The minimum predicted value of a pruned CART tree fitted to the curve of the standard deviations of VI.
A vector of the variables importance means (over
nfor.thres
runs), in decreasing order.
The ordering index vector associated to the sorting of variables importance means.
A vector of standard deviations of all variables
importance. The order is given by imp.mean.dec.ind
.
Mean OOB error rate, obtained by a random forests build on all variables.
Predictions of the CART tree fitted to the curve of the standard deviations of VI.
A vector of the mean OOB error rates of the embedded random forests models build during the "interpretation step".
The standard deviation of OOB error rates associated to the random forests model attaining the minimum mean OOB error rate during the "interpretation step".
A vector of the mean OOB error rates of the random forests models build during the "prediction step".
The mean jump value computed during the "prediction step".
Corresponding parameters values.
Overall computation time.
A list of the 3 computation times respectively associated with the 3 steps: "thresholding", "interpretation" and "prediction".
The RF implementation used to run VSURF
,
among "randomForest" (default), "ranger" and "Rborist" or a vector of length
3 with those.
The number of cores used to run VSURF
in parallel (NULL
if VSURF did not run in parallel).
The type of the cluster used to run VSURF
in
parallel (NULL if VSURF did not run in parallel).
The original call to VSURF
.
Terms associated to the formula (only if formula-type call was used).
Method used to deal with missing values (only if formula-type call was used).
A data frame or a matrix of predictors, the columns represent the variables. Or a formula describing the model to be fitted.
others parameters to be passed on to the randomForest
function (see ?randomForest for further information).
A response vector (must be a factor for classification problems and numeric for regression ones).
Number of trees in each forests grown. Standard parameter of
randomForest
.
Number of variables randomly sampled as candidates at each split.
Standard parameter of randomForest
.
Number of forests grown for "thresholding step" (first of the three steps).
Number of times the "minimum value" is multiplied to set threshold value. See details below.
Number of forests grown for "interpretation step" (second of the three steps).
Number of times the standard deviation of the minimum value of
err.interp
is multiplied. See details below.
Number of forests grown for "prediction step" (last of the three steps).
Number of times the mean jump is multiplied. See details below.
Choice of the random forests implementation to use :
"randomForest" (default), "ranger" or "Rborist" (not that if "Rborist" is
chosen, "randoForest" will still be used for the first step
VSURF_thres
). If a vector of length 3 is given, each coordinate is
passed to each intermediate function: VSURF_thres
,
VSURF_interp
, VSURF_pred
, in this order.
A logical indicating if you want VSURF to run in parallel on
multiple cores (default to FALSE). If a vector of length 3 is given,
each coordinate is passed to each intermediate function: VSURF_thres
,
VSURF_interp
, VSURF_pred
, in this order.
Number of cores to use. Default is set to the number of cores detected by R minus 1.
Type of the multiple cores cluster used to run VSURF in
parallel. Must be chosen among "PSOCK" (default: SOCKET cluster available
locally on all OS), "FORK" (local too, only available for Linux and Mac
OS), "MPI" (can be used on a remote cluster, which needs snow
and
Rmpi
packages installed), "ranger" and "Rborist" for internal
parallelizations of those packages (not that if "Rborist" is
chosen, "SOCKET" will still be used for the first step
VSURF_thres
). If a vector of length 2 is given, each
coordinate is passed to each intermediate function: VSURF_thres
,
VSURF_interp
, in this order.
A logical indicating if information about method's progress (included progress bars for each step) must be printed (default to TRUE). Adds a small extra overload.
a data frame containing the variables in the model.
A function to specify the action to be taken if NAs are
found. (NOTE: If given, this argument must be named, and as
randomForest
it is only used with the formula-type call.)
Robin Genuer, Jean-Michel Poggi and Christine Tuleau-Malot
First step ("thresholding step"): first, nfor.thres
random forests are computed using the function randomForest
with
arguments importance=TRUE
, and our choice of default values for
ntree
and mtry
(which are higher than default in
randomForest
to get a more stable variable importance measure).
Then variables are sorted according to their mean variable importance (VI),
in decreasing order. This order is kept all along the procedure. Next, a
threshold is computed: min.thres
, the minimum predicted value of a
pruned CART tree fitted to the curve of the standard deviations of VI.
Finally, the actual "thresholding step" is performed: only variables with a
mean VI larger than nmin
* min.thres
are kept.
Second step ("interpretation step"): the variables selected by the
first step are considered. nfor.interp
embedded random forests models
are grown, starting with the random forest build with only the most important
variable and ending with all variables selected in the first step. Then,
err.min
the minimum mean out-of-bag (OOB) error of these models and
its associated standard deviation sd.min
are computed. Finally, the
smallest model (and hence its corresponding variables) having a mean OOB
error less than err.min
+ nsd
* sd.min
is selected.
Note that for this step (and the next one), the mtry
parameter of
randomForest
is set to its default value (see
randomForest
) if nvm
, the number of variables in the
model, is not greater than the number of observations, while it is set to
nvm/3
otherwise. This is to ensure quality of OOB error estimations
along embedded RF models.
Third step ("prediction step"): the starting point is the same than in
the second step. However, now the variables are added to the model in a
stepwise manner. mean.jump
, the mean jump value is calculated using
variables that have been left out by the second step, and is set as the mean
absolute difference between mean OOB errors of one model and its first
following model. Hence a variable is included in the model if the mean OOB
error decrease is larger than nmj
* mean.jump
.
As for interpretation step, the mtry
parameter of randomForest
is set to its default value if nvm
, the number of variables in the
model, is not greater than the number of observations, while it is set to
nvm/3
otherwise.
VSURF is able to run using multiple cores in parallel (see parallel
,
clusterType
and ncores
arguments).
Genuer, R. and Poggi, J.M. and Tuleau-Malot, C. (2010), Variable selection using random forests, Pattern Recognition Letters 31(14), 2225-2236
Genuer, R. and Poggi, J.M. and Tuleau-Malot, C. (2015), VSURF: An R Package for Variable Selection Using Random Forests, The R Journal 7(2):19-33
plot.VSURF
, summary.VSURF
,
VSURF_thres
, VSURF_interp
,
VSURF_pred
, tune
data(iris)
iris.vsurf <- VSURF(iris[,1:4], iris[,5], ntree = 100, nfor.thres = 20,
nfor.interp = 10, nfor.pred = 10)
iris.vsurf
if (FALSE) {
# A more interesting example with toys data (see \code{\link{toys}})
# (a few minutes to execute)
data(toys)
toys.vsurf <- VSURF(toys$x, toys$y)
toys.vsurf
# VSURF run on 2 cores in parallel (using a SOCKET cluster):
data(toys)
toys.vsurf.parallel <- VSURF(toys$x, toys$y, parallel = TRUE, ncores = 2)
}
Run the code above in your browser using DataLab