Introduction
After building a model, understanding which features matter most is crucial for interpretation, feature engineering, and model simplification. Variable importance quantifies each feature's contribution to predictive performance.
There is no single "correct" way to measure importance — different methods answer different questions and may yield different rankings. Below we survey the most common approaches, from model-specific to fully model-agnostic.
Model-Specific Methods
Linear Models
In a linear regression \(y = \beta_0 + \beta_1 x_1 + \dots + \beta_p x_p + \varepsilon\), the natural measure of importance for feature \(j\) is the absolute value of the t-statistic:
\[ \text{Importance}(j) = \left| \frac{\hat\beta_j}{\text{SE}(\hat\beta_j)} \right| = |t_j| \]
To compare coefficients across features measured on different scales, use standardized coefficients:
\[ \hat\beta_j^{\text{std}} = \hat\beta_j \cdot \frac{s_{x_j}}{s_y} \]
where \(s_{x_j}\) and \(s_y\) are the sample standard deviations of feature \(j\) and the response, respectively.
Tree-Based Models — Mean Decrease in Impurity (MDI)
For tree-based models (CART, Random Forest, Gradient Boosting), Mean Decrease in Impurity measures the total reduction in the splitting criterion (Gini impurity for classification, RSS for regression) attributed to splits on variable \(j\), averaged over all trees:
\[ \text{Imp}(j) = \sum_{t:\, \text{split on } j} \Delta I(t) \cdot p(t) \]
where:
- \(\Delta I(t)\) = reduction in impurity at node \(t\)
- \(p(t) = n_t / N\) = proportion of samples reaching node \(t\)
For an ensemble of \(B\) trees, the final importance is averaged: \(\text{Imp}(j) = \frac{1}{B} \sum_{b=1}^{B} \text{Imp}_b(j)\).
Caveat: MDI is biased towards high-cardinality features and features with many possible split points.
Random Forest — Mean Decrease Accuracy (MDA)
Also known as permutation importance computed on the Out-of-Bag (OOB) samples:
- For each tree \(b\), compute OOB accuracy \(\text{Acc}_b\)
- Permute feature \(j\) in the OOB samples, recompute accuracy \(\text{Acc}_b^{(\pi_j)}\)
- Importance: \[ \text{MDA}(j) = \frac{1}{B} \sum_{b=1}^{B} \left( \text{Acc}_b - \text{Acc}_b^{(\pi_j)} \right) \]
This is more reliable than MDI as it uses OOB data (unseen by each tree) and is less biased by cardinality.
Permutation Importance (Model-Agnostic)
Permutation importance generalizes the Random Forest MDA idea to any model. The algorithm:
- Train model \(f\) on training data. Compute baseline score on the test set: \(s_0 = \text{Score}(f, X_{\text{test}}, y_{\text{test}})\)
- For each feature \(j = 1, \dots, p\):
- Randomly shuffle (permute) column \(j\) in \(X_{\text{test}}\)
- Recompute score: \(s_j = \text{Score}(f, X_{\text{test}}^{(\pi_j)}, y_{\text{test}})\)
- Importance of feature \(j\): \[ \text{PI}(j) = s_0 - s_j \]
A large drop in performance indicates high importance.
Advantages
- Works for any model (linear, tree, neural network, etc.)
- Computed on held-out test data — reflects generalization, not training fit
- Captures interaction effects (shuffling a feature breaks all its interactions)
Disadvantages
- Correlated features: if features \(j\) and \(k\) are highly correlated, permuting \(j\) alone may not degrade performance much (because \(k\) carries similar information), leading to underestimation of both
- Stochastic — results vary across random permutations (repeat and average)
SHAP Values
SHAP (SHapley Additive exPlanations) is based on Shapley values from cooperative game theory. The Shapley value of feature \(j\) for observation \(i\) represents the average marginal contribution of that feature across all possible coalitions of features.
\(\phi_j^{(i)}\) = contribution of feature \(j\) to the prediction for observation \(i\).
The formula:
\[ \phi_j = \sum_{S \subseteq F \setminus \{j\}} \frac{|S|!\;(|F| - |S| - 1)!}{|F|!} \left[ f(S \cup \{j\}) - f(S) \right] \]
where \(F\) is the full feature set, \(S\) is a subset not containing \(j\), and \(f(S)\) denotes the model prediction using only features in \(S\) (with the remaining features marginalized out).
Key Properties
- Local explanation: each prediction gets its own feature attributions
- Additivity: \[ f(x) = \phi_0 + \sum_{j=1}^{p} \phi_j \] where \(\phi_0 = E[f(X)]\) is the baseline (average prediction)
- Consistency: if a feature's marginal contribution increases in a new model, its SHAP value does not decrease
- Symmetry: features that contribute equally get equal SHAP values
For global importance, aggregate across observations:
\[ \text{SHAP Importance}(j) = \frac{1}{n} \sum_{i=1}^{n} |\phi_j^{(i)}| \]
Drop-Column Importance
The most straightforward (and most computationally expensive) approach:
- Train the full model with all features: \(s_{\text{full}} = \text{Score}(f_{\text{all}})\)
- For each feature \(j\): retrain the model without feature \(j\): \(s_{-j} = \text{Score}(f_{-j})\)
- Importance: \[ \text{DCI}(j) = s_{\text{full}} - s_{-j} \]
Why it's the gold standard
- Fully accounts for correlations — if \(j\) is redundant with \(k\), the model without \(j\) will still use \(k\)
- No permutation artifacts
- Reflects the model's ability to compensate for a missing feature
Main drawback
Requires \(p + 1\) full model trainings. For large \(p\) or expensive models, this is often infeasible.
Caveats and Best Practices
- Correlated features split importance: with any method, two correlated features will each appear less important than they truly are (their combined effect is shared). Consider grouping or removing one.
- Use permutation importance on test data: training-set importance can be inflated by overfitting.
- Combine multiple methods: MDI, permutation, and SHAP may disagree. Use them together for a more robust picture.
- Importance ≠ causality: a feature can be highly important for prediction without being a causal driver of the outcome. Observational importance reflects association, not mechanism.
- Scale matters: for coefficient-based methods, always standardize or use t-statistics rather than raw coefficients.
- Stability: repeat permutation-based methods multiple times and report mean ± standard deviation.