Permutation importance
Quick answer
Permutation importance measures how much a fitted model’s score changes when one feature is shuffled on an evaluation dataset. It describes reliance under a particular score and perturbation scheme. Static examples tested locally with Python 3.13.5, scikit-learn 1.8.0 SciPy 1.17.0 and NumPy 2.3.5 where imported. ByteMind package execution is unverified.
Calculate a score drop
base=-2; scores=[-3,-5,-4]print([base-s for s in scores],sum(base-s for s in scores)/len(scores))Observed local output:
[1, 3, 2] 2.0The negative-MSE score gets smaller as error increases.
How it works
For a larger-is-better score S, importance I_j=S(X,y)-mean_r S(X with feature j permuted,y). For negative MSE scoring, this equals an increase in MSE. Fit once; never refit on the permuted rows. Use held-out evaluation data and multiple random permutations. Record mean and spread across repeats, not a population confidence interval. A negative importance is possible, for example when a noisy feature harms predictions or finite sampling varies. Correlated substitutes may each have low importance if the other preserves the signal; alternatively shuffling may break realistic combinations and exaggerate the drop. A shared permutation of a group preserves within-group associations and measures reliance on the group, not a sum of independent effects. Compare individual and joint results on the same evaluation rows. Use the same scoring convention when comparing methods.
Shuffle a useful feature on held-out rows
import numpy as npfrom sklearn.linear_model import LinearRegressionfrom sklearn.inspection import permutation_importanceX=np.array([[a,b] for a in range(6) for b in [0,1]])y=3*X[:,0]m=LinearRegression().fit(X[:8],y[:8])r=permutation_importance(m,X[8:],y[8:],scoring="neg_mean_squared_error",n_repeats=20,random_state=7)print((r.importances_mean>1e-8).tolist())Observed local output:
[True, False]The first feature is used by this fitted model; the second does not materially change its score.
Common mistakes
Do not use permutation importance to prove a feature causes the outcome. Do not shuffle y, fit a new model each repeat, or assume zero importance means no predictive information in the feature. Do not call repeat standard deviation a confidence interval.
Practice and next steps
Given baseline negative MSE -2 and shuffled scores -3,-5,-4, calculate average importance. Repeat with a group of correlated columns. Complete the knowledge check and staged exercise. Next: Partial dependence and ICE.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Permutation importance — knowledge check
Apply permutation importance to new scenarios.
Why freeze the fitted model?
Baseline score -2 and shuffled score -5 give?
Can a negative importance occur?
Two features substitute for each other. What may individual importance show?
Why use one permutation for a feature group?