tidy.gbm: tidy up the model summary of gbm

View source: R/tidy-gbm.R

tidy.gbmR Documentation

tidy up the model summary of gbm

Description

tidy returns a tibble of variable importance for the rpart pacakge

Usage

## S3 method for class 'gbm'
tidy(x, n_trees = x$n.trees, scale = FALSE, sort = TRUE, normalise = TRUE, ...)

Arguments

x

A gbm model

n_trees

integer. (optional) Number of trees to use for computing relative importance. Default is the number of trees in x$n.trees. If not provided, a guess is made using the heuristic: If a test set was used in fitting, the number of trees resulting in lowest test set error will be used; else, if cross-validation was performed, the number of trees resulting in lowest cross-validation error will be used; otherwise, all trees will be used.

scale

(optional) Should importance be scaled? Default is FALSE

sort

(optional) Should results be sorted? Default is TRUE

normalise

(optional) Should results be normalised to sum to 100? Default is TRUE

...

extra functions or arguments

Value

A tibble containing the importance score for each variable

Examples


# retrieve a tibble of the variable importance from an gbm model

library(gbm)
library(MASS)
fit_gbm <- gbm(calories ~., data = UScereal)

tidy(fit_gbm)


njtierney/broomstick documentation built on Dec. 12, 2023, 5:08 a.m.