Permutation feature importance estimates a feature’s contribution by measuring how much model performance worsens after that feature’s values are randomly shuffled. Shuffling breaks the relationship between the feature and predictions without requiring access to model internals, making the method model-agnostic. section 9.3.1
Compute the score as a before-and-after comparison:
- Evaluate the trained model on a hold-out test set. section 9.3.1
- Randomly permute one feature’s values across the test examples. section 9.3.1
- Evaluate the model again and measure the increase in test error, repeating the process for every feature. section 9.3.1
- Interpret larger performance degradation as evidence that the feature contributes more to predictions; a small change suggests weaker contribution. section 9.3.1
XGBoost with scikit-learn
Apply permutation importance to an XGBoost model with scikit-learn’s permutation_importance function, using a hold-out test set, balanced accuracy as the scoring metric, and 30 repeats. Different metrics can produce different importance results, such as balanced accuracy versus recall. section 9.3.1
Figure 9.7 The procedure for computing permutation feature importance illustrated for the third feature. This procedure is repeated for all features. Permutation feature importance uses only inputs and outputs to estimate feature importance and doesn’t use model internals (making this a model-agnostic approach).
Follow the visual procedure for permuting one feature, measuring the performance change, and repeating the calculation across all features. section 9.3.1

