rf_filter: Random forest filter

View source: R/filters.R

rf_filterR Documentation

Random forest filter

Description

Fits a random forest model and ranks variables by variable importance.

Usage

rf_filter(
  y,
  x,
  nfilter = NULL,
  type = c("index", "names", "full"),
  ntree = 1000,
  mtry = ncol(x) * 0.2,
  ...
)

Arguments

y

Response vector

x

Matrix of predictors

nfilter

Number of predictors to return. If NULL all predictors are returned.

type

Type of vector returned. Default "index" returns indices, "names" returns predictor names, "full" returns a named vector of variable importance.

ntree

Number of trees to grow. See randomForest.

mtry

Number of predictors randomly sampled as candidates at each split. See randomForest.

...

Optional arguments passed to randomForest.

Details

This filter uses the randomForest function from the randomForest package. Variable importance is calculated using the importance function, specifying type 1 = mean decrease in accuracy. See importance.

Value

Integer vector of indices of filtered parameters (type = "index") or character vector of names (type = "names") of filtered parameters. If type is "full" a named vector of variable importance is returned.


nestedcv documentation built on Oct. 23, 2022, 5:06 p.m.