Integrated gradients and PDPs both probe an already-trained model from the outside, after the fact. A decision tree already knows exactly which feature did the most work — it decided that at every single split, while training. Reading it back out costs nothing extra.
Step through each node in a small tree and see which feature it picked, and how much impurity that split actually removed. The root's choice and the child's choice don't have to be the same feature at all.
At every node, a tree tries every feature's best threshold and keeps whichever gives the highest information gain. Feature importance just adds up that gain, weighted by how many samples reached each node, per feature, across the whole tree:
- — the total importance score credited to feature across the whole tree.
- — the feature being scored, i.e. whichever feature a node happened to split on.
- — the number of samples that reached a given splitting node.
- — the total number of samples in the whole tree.
- — the reduction in impurity that node's split achieved.
- No separate explanation step needed
No perturbation, no gradients, no extra pass over the data — nothing this method needs isn't already produced by ordinary training.
- The number exists the moment training ends
The importance score was already computed the moment the tree finished training; reading it back out is free.
x1 wins the root split, using every sample the tree has. x2 only ever gets used once, deeper in the tree, on a small subset — and still ends up with real, substantial importance, because that one split it does make is a clean, high-gain one.
Eight points, two features. x1 orders the classes almost perfectly; one point is mislabeled relative to x1 alone:
- The root split: x1, using all 8 samples
Threshold on x1 gives information gain , weighted by all samples: .
- The left child: x2 catches the one exception
Among the 4 points that reached the left child, one has a label that x1 alone would get wrong. A split on x2 at threshold isolates it perfectly — gain , weighted by of the total samples: .
- The right child needed nothing
All 4 points on the other side of the root split already share the same label — the best possible split there has gain , and contributes nothing to either feature's importance.
Normalizing and to sum to : x1 , x2 — x1 clearly the bigger contributor, but x2 far from irrelevant.
Find the one point, among these three, whose label doesn't match what x1 alone would predict.
Tree-based importance is the cheapest explanation method in this course — it requires training the model once, and nothing more. That's also its limit: it can only ever describe what the training procedure found useful for reducing impurity, which isn't automatically the same as what matters for a specific prediction, or what a human would consider the "true" cause. The next chapter asks for something tree importance can't give at all: a simple, human-readable rule that guarantees a specific prediction, not just a ranked list of contributing features.