Ranking the variable importance with the caret package

After building a supervised learning model, we can estimate the importance of features. This estimation employs a sensitivity analysis to measure the effect on the output of a given model when the inputs are varied. In this recipe, we will show you how to rank the variable importance with the caret package.

Getting ready

You need to have completed the previous recipe by storing the fitted rpart object in the model variable.

How to do it...

Perform the following steps to rank the variable importance with the caret package:

  1. First, you can estimate the variable importance with the varImp function:
    > importance = varImp(model, scale=FALSE)
    > importance
    rpart variable importance
    
                                  Overall
    number_customer_service_calls ...

Get R: Recipes for Analysis, Visualization and Machine Learning now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.