imbs-hl / ranger

A Fast Implementation of Random Forests
http://imbs-hl.github.io/ranger/
771 stars 193 forks source link

Enhancement: varUsed Convenience Function #641

Open DarioS opened 1 year ago

DarioS commented 1 year ago

It would be nice to be able to easily discover which variables are ever used and which aren't, like varUsed in randomForest.

Variables Used in a Random Forest Description Find out which predictor variables are actually used in the random forest. Usage varUsed(x, by.tree = FALSE, count = TRUE) [Package randomForest version 4.7-1.1]

snembrini commented 8 months ago

Hey Dario, I know it's been a year, but I hope this helps (see attached function


rg.iris <- ranger(Species ~ ., data = iris, importance = "impurity",num.trees = 100) varUsedRanger(rg.iris,by.tree = F,percent = T)

varUsedRanger.txt