importance_table returns a data_frame of variable importance for decision trees methods rpart randomForest, and gbm.step (from the dismo package).

importance_table(x, ...)

Arguments

x
An rpart, randomForest, or gbm.step, or model
...
extra functions or arguments

Value

A tibble containing the importance score made with the intention of turning it into a text table with `knitr` or `xtable`

Note

treezy currently only works for rpart and gbm.step functions. In the future more features will be added so that it works for many decision trees

https://github.com/dgrtwo/broom

Examples

# retrieve a tibble of the variable importance from a decision tree model ## Not run: ------------------------------------ # # rpart object # library(rpart) # fit_rpart <- rpart(Kyphosis ~ Age + Number + Start, data = kyphosis) # # importance_table(fit_rpart) # # # you can even use piping # # fit_rpart %>% importance_table # # # gbm.step object # # library(dismo) # library(gbm) # # fit_gbm_step <- gbm.step(data = iris, # gbm.x = c(1:3), # gbm.y = 4, # tree.complexity = 1, # family = "gaussian", # learning.rate = 0.01, # bag.fraction = 0.5) # # importance_table(fit_gbm_step) # # # with piping # fit.gbm.step %>% importance_table # # Unfortunately it cannot yet run a gbm object: # # # gbm.fit <- gbm(Sepal.Width ~ ., # distribution = "gaussian", # data = iris) # # importance_table(gbm.fit) # # # #A randomForest object # set.seed(1) # data(iris) # fit_rf <- randomForest(Species ~ ., iris, # proximity=TRUE, # keep.forest=FALSE) # # importance_table(fit_rf) # ## ---------------------------------------------