Learn R Programming

BioMedR (version 1.2.1)

rf.fs: Random Forest Cross-Valdidation for feature selection

Description

Random Forest Cross-Valdidation for feature selection

Usage

rf.fs(trainx, trainy, cv.fold = 5, scale = "log", step = 0.5,
  mtry = function(p) max(1, floor(sqrt(p))), recursive = FALSE)

Arguments

trainx

matrix or data frame containing columns of predictor variables

trainy

vector of response, must have length equal to the number of rows in trainx

cv.fold

The fold, the defalut is 5.

scale

If "log", reduce a fixed proportion (step) of variables at each step, otherwise reduce step variables at a time

step

If log=TRUE, the fraction of variables to remove at each step, else remove this many variables at a time

mtry

A function of number of remaining predictor variables to use as the mtry parameter in the randomForest call

recursive

Whether variable importance is (re-)assessed at each step of variable reduction

Value

A list with the following three components::

  • n.var - vector of number of variables used at each step

  • error.cv - corresponding vector of error rates or MSEs at each step

  • res - list of n.var components, each containing the feature importance values from the cross-validation

Details

This function shows the cross-validated prediction performance of models with sequentially reduced number of predictors (ranked by variable importance) via a nested cross-validation procedure.

References

Svetnik, V., Liaw, A., Tong, C. and Wang, T., Application of Breiman's Random Forest to Modeling Structure-Activity Relationships of Pharmaceutical Molecules, MCS 2004, Roli, F. and Windeatt, T. (Eds.) pp. 334-343.

See Also

See rf.cv for the Cross-Validation of Classification and Regression models using Random Forest

Examples

Run this code
# NOT RUN {
training = read.csv(system.file('sysdata/training1.csv', package = 'BioMedR'), header = TRUE)
y = training[, 1]
x = training[, -1]
result = rf.fs(x, y)

# }

Run the code above in your browser using DataLab