Description
Description
"Feature contributions" meaning, the effects of each feature's value on a given prediction. This concept is explained well in this paper. I've written code that uses the method described in section 3 of that paper, moving down the path of the tree to get these "feature contributions" in each tree as the paper describes, then averaging them over all trees.
The code I've written calculates this at the same time that it does the actual predictions (i.e. in the same "while child node is not a leaf" loop) and returns both. We need to follow the sample's path down the tree to calculate the prediction anyway, so it was much faster to do this at the same time that the contributions were calculated rather than moving down the same path of the tree two separate times, once for the prediction and once for the contributions.
So I have a method called something like "predict_with_contributions". I'd also be open to splitting off the feature contributions calculation into it's own method if having both in the same method sounds too messy/confusing. If I were to do this, it might make sense for the code to use the get_decision_path code from this PR: #5487