count_variables: count the number of times each variable is used in a ranger...

View source: R/count_variables.R

count_variablesR Documentation

count the number of times each variable is used in a ranger random forest

Description

  • count the number of times each variable is used in a ranger random forest.

  • help(treeInfo) warns "splitvarID – ID of the splitting variable, 0-indexed. Caution, the variable order changes if the formula interface is used" However this should be investigated

Usage

count_variables(object)

Arguments

object

a ranger forest object

Value

a table (0-indexed) giving the number of times each variable was used in the random forest

Examples

library(ranger)
rf1 <- ranger(Species ~ ., data = iris,importance="impurity", seed=123)
count_variables(rf1)
rf2 <- ranger(dependent.variable.name = "Species", data = iris,seed=123)
count_variables(rf2)
rf3<- ranger(y = iris[, 5], x = iris[, -5],seed=123)
count_variables(rf3)


RFlocalfdr documentation built on April 4, 2025, 5:16 a.m.