Responsible AI & Behavioural

Why Feature Importance Misleads

Understanding how Gini Impurity feature importance in tree models misleads developers on correlated and high cardinality features.

🔴 advanced5 min readinterpretability
Why Feature Importance Misleads explores common pitfalls when interpreting model feature rankings. Default Gini Impurity feature importances in decision trees heavily bias toward continuous and high cardinality features. Additionally, correlated features split importance scores artificially, hiding critical signals. Engineers use Permutation Feature Importance and SHAP values to obtain unbiased feature rankings.

The Illusion of Default Feature Importance

In Python libraries like Scikit-Learn or XGBoost, developers frequently call model.feature_importances_ to explain their models.

Relying blindly on default feature importance output leads to dangerous misinterpretations.

Default tree feature importance (MDI / Gini Importance) calculates how much each feature split reduces impurity. This calculation suffers from Two Severe Flaws:

FLAW 1: Cardinality Bias ──► High cardinality features (IDs, Zip Codes) get artificially inflated scores!
FLAW 2: Correlation Split ──► Strongly correlated features split importance scores, making both look weak!

Flaw 1: Cardinality Bias (High Cardinality Inflation)

Features with many unique values (like User_ID, Random_Noise_Float, ZIP_Code) offer thousands of candidate split thresholds.

Tree algorithms split on these high cardinality features repeatedly by chance, artificially inflating their Gini importance scores even if the column is pure random noise!

Feature Experiment:
- Feature 1: True Binary Signal (0 or 1)      ──► Gini Importance = 0.15 (Looks Low!)
- Feature 2: Pure Random Float (High Card)    ──► Gini Importance = 0.85 (Looks High!)

Default Gini importance ranks pure random noise as the most important feature!

Flaw 2: Correlation Masking

When two features $X_1$ and $X_2$ are strongly correlated (for example House_Square_Feet and Room_Count):

Unbiased Alternatives

┌──────────────────────────┬──────────────────────────┐
│ PERMUTATION IMPORTANCE   │ SHAP VALUES              │
├──────────────────────────┼──────────────────────────┤
│ Shuffles a single feature│ Computes game theoretic  │
│ column on test data and  │ marginal contributions   │
│ measures performance drop| across all feature       │
│ score. Model agnostic!   │ combinations. Gold std!  │
└──────────────────────────┴──────────────────────────┘

Permutation Feature Importance

  1. Compute baseline validation score $S_{\text{base}}$ on clean test set.
  2. Randomly shuffle the values of feature column $j$ in the test set, breaking its relationship with target $y$.
  3. Compute new validation score $S_{\text{shuffled}}$.
  4. Importance $= S_{\text{base}} - S_{\text{shuffled}}$.

If shuffling feature $j$ causes validation performance to collapse, feature $j$ is genuinely important!

Say this out loud

Default Gini feature importance in tree models misleads developers by inflating high cardinality features and splitting scores across correlated variables. Permutation feature importance and SHAP values provide unbiased alternatives. Permutation importance shuffles individual test features to measure true validation performance drops.

Followups to expect

  1. Why does Permutation Importance struggle with correlated features? Shuffling one correlated feature creates unrealistic out-of-distribution sample combinations (for example 5,000 square foot house with 1 room), overestimating performance drops.
  2. What is Drop Column Importance? Retraining a model from scratch after dropping a feature column entirely, measuring true baseline performance drops at the cost of high compute time.

Check yourself

Question 1 of 3

Why does default Gini Impurity Feature Importance in Random Forests heavily bias toward high cardinality features like User ID or ZIP code?

More in Responsible AI & Behavioural

See all →
Telling Your ML Project Story5 minBias & Fairness in ML5 minExplainability: SHAP & LIME4 min