reduce.surrogates: Reduce surrogate variables in a random forest.

View source: R/reduce.surrogates.R

reduce.surrogatesR Documentation

Reduce surrogate variables in a random forest.

Description

This function can be applied to reduce the surrogate variables in a forest that is created by getTreeranger, addLayer and getSurrogates functions. Hence, it can be applied to the forests that were used for surrogate minimal depth variable importance.

Usage

reduce.surrogates(forest, s = 10)

Arguments

forest

a list containing allvariables and trees. Allvariables is a vector of all variable names in the original data set (strings). Trees is a list of trees that was generated by getTreeranger, addLayer, and getSurrogates functions.

s

number of surrogate variables in the new forest (have to be less than in the RF in trees)

Value

forest with s surrogate variables.

Examples

# read data
data("SMD_example_data")

###### use result of SMD variable importance and reduce surrogate variables to 10
# select variables with smd variable importance (usually more trees are needed)
set.seed(42)
res = var.select.smd(x = SMD_example_data[,2:ncol(SMD_example_data)], y = SMD_example_data[,1], s = 100, ntree = 10)
forest.new = reduce.surrogates(forest = res$forest, s = 10)

# execute SMD on tree with reduced number of surrogates
res.new = var.select.smd(create.forest = FALSE, forest = forest.new)
res.new$var

#' # investigate variable relations
rel = var.relations(forest = forest.new, variables=c("X1","X7"), candidates = res$forest[["allvariables"]][1:100], t = 5)
rel$var


StephanSeifert/SurrogateMinimalDepth documentation built on Aug. 7, 2023, 1:59 a.m.