select_trees: Select most representative trees of a random forest

View source: R/select_trees.R

select_treesR Documentation

Select most representative trees of a random forest

Description

select_trees uses pair-wise dissimilarity of trees in a random forest trained with ranger to identify the most representative trees from the ensemble

Usage

select_trees(rf, num.trees = NULL, distance.matrix = NULL)

Arguments

rf

Object of class ranger used with write.forest = TRUE to select trees from.

num.trees

Number of trees to be selected from rf.

distance.matrix

Add matrix of precalculated distances.

Value

rep.trees

ranger object containing the most representative trees

Author(s)

Dr. Bjoern-Hergen Laabs

Examples

require(ranger)
require(timbR)

## Train random forest with ranger
rg.iris <- ranger(Species ~ ., data = iris, write.forest=TRUE, num.trees = 10)

## Calculate pair-wise distances for all trees
distances <- measure_distances(rf = rg.iris, metric = "splitting variables")

## Select 5 most representative trees
rg.iris.rep <- select_trees(rf = rg.iris, num.trees = 5, distance.matrix = distances)



imbs-hl/timbR documentation built on April 17, 2025, 2:08 p.m.