Skip to contents

Calculate feature importance in terms of xgboost metrics and shap values

Usage

getFeatureImp(model, data, outcome)

Arguments

model

output xgboost model from `buildXGboost()`

data

dataframe, input data used to train the model

outcome

string, name of the outcome variable

Value

a data frame that contains 4 metrics for each feature

  • Gain: improvement in accuracy brought by the feature to the branches it is on

  • Cover: relative quantity of observations concerned by a feature

  • Frequency: the number of times a feature is used in all generated trees

  • shap: average Shapley value for the feature

Examples

if (FALSE) { # \dontrun{
getFeatureImp(xgb, voteData, "vote")
} # }