get_varImp: Get tidy variable importance information from a...

View source: R/get_varImp.R

get_varImpR Documentation

Get tidy variable importance information from a caret::train object

Description

Function to return a tidy dataframe with variable importance information from a model trained by caret::train. Appends the algorithm and outcome information.

Usage

get_varImp(trained.model)

Arguments

trained.model

Result of a train() call in caret.

Details

Currently shows a warning and returns an empty dataframe whenever the call to caret::varImp() returns an error (e.g., if that algorithm has no variable importance metrics).

Writing this as a function that tidily gets variable importance (rather than tidies variable importance returned by varImp) is necessary for the mutate+map paradigm, as calls will otherwise be interrupted by errors.

Examples

model1 <- caret::train(data = mtcars, mpg ~ ., method = "glm")
get_varImp(model1)

# this one will show a warning and return empty dataframe
model2 <- caret::train(data = mtcars, mpg ~ ., method = "ranger")
get_varImp(model2)

wepelham3/sack2 documentation built on Aug. 5, 2023, 5:53 a.m.