liveBook · Manning

Permutation feature importance

As explained in Ensemble Methods for Machine Learning

Permutation feature importance estimates a feature's contribution by measuring the change in model performance after that feature's values are randomly permuted.

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).
CH09_F07_Kunapuli

Follow the visual procedure for permuting one feature, measuring the performance change, and repeating the calculation across all features. section 9.3.1

How Ensemble Methods for Machine Learning covers it

How deep it goes
Explains the shuffle-and-reevaluate procedure, test-set requirement, metric choice, and repeated computation across features.
Examples
Uses an XGBoost model evaluated with balanced accuracy or recall and 30 permutation repeats.
What it assumes
Assumes a trained predictive model, a hold-out test set, and a task-appropriate performance metric.
What you can do after
Apply it via scikit-learn to rank features by their effect on hold-out predictive performance.
How it connects
Contrasts with decision-tree feature importance and complements partial dependence plots, surrogate models, LIME, and SHAP.

Also explained in

Compare how 2 books explain permutation feature importance →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Ensemble Methods for Machine Learning. The section links point to the parts of the book it draws on.