Learn R Programming

RFlocalfdr (version 0.9)

count_variables: 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)

Value

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

Arguments

object

a ranger forest object

Examples

Run this code
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)

Run the code above in your browser using DataLab