Machine Learning, FoundationsLesson 61 of 92

Module 6 · Trees, ensembles, and the algorithms that win on tables

Feature importance, and the ways it misleads

In this lesson

  • 9 min read
  • 6 reading sections
  • Knowledge check
  • Lesson 9 of 10 in this chapter

This chapter’s goalChoose between a linear model, a random forest and a gradient boosting library for a given tabular problem and defend the choice, tune the four hyperparameters that actually matter in each, and explain why impurity-based feature importance is biased and what permutation importance and SHAP replace it with.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmWatch1:59Not available
Full audiobookNot availableNot available
Impurity importance with a column of random noise addeddays_since_last_purchase0.27random integers 1 to10,0000.19monthly_spend0.16tenure_months0.12is_verified (binary)0.04has_complained (binary)0.03share of total impurity decrease, computed on training rowsThe random column offers 10,000 candidate thresholds, so by chance some split reduces impurity, and itlands second: above two binary columns that genuinely predict the target. Nothing is broken. Themetric measures what it says it measures, on training data, and that is not what you wanted.
The random column offers 10,000 candidate thresholds, so by chance some split reduces impurity, and it lands second: above two binary columns that genuinely predict the target. Nothing is broken. The metric measures what it says it measures, on training data, and that is not what you wanted.

Figure

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 8Free · no account needed
Lesson steps

The number everybody prints

Python
model.feature_importances_

One line, a satisfying bar chart, and a plausible story about what drives the outcome. It is also, in its default form, systematically biased in ways that are easy to demonstrate and rarely mentioned.

What impurity importance actually measures

For a tree ensemble, the default importance sums the impurity decrease each feature achieved across all splits, weighted by how many rows passed through those nodes.

That definition contains two biases.

Bias towards high-cardinality features. A feature with many distinct values offers many candidate thresholds, so by chance one of them will reduce impurity. Continuous features and high-cardinality categoricals therefore accumulate importance even when they carry no signal.

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Every lesson here is open. Your progress is recorded once you pass the How a Language Model Actually Works exam.

Stuck on something?Ask Funke, your AI tutor

How to cite: Addaly (2026) ‘Feature importance, and the ways it misleads’, in Machine Learning, Foundations. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/machine-learning-foundations/feature-importance-and-its-lies (Accessed: 29 November 2026).