get_varImp | R Documentation |
caret::train
objectFunction to return a tidy dataframe with variable importance information
from a model trained by caret::train
. Appends the algorithm and outcome information.
get_varImp(trained.model)
trained.model |
Result of a |
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.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.