View source: R/reduce.surrogates.R
reduce.surrogates | R Documentation |
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.
reduce.surrogates(forest, s = 10)
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) |
forest with s surrogate variables.
# 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.