Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PySpark GBT Issue #2700

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion shap/explainers/_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ def buildTree(index, node):
self.values[index] = [node.prediction()] #prediction for the node
else:
self.values[index] = [e for e in node.impurityStats().stats()] #for gini: NDarray(numLabel): 1 per label: number of item for each label which went through this node
self.node_sample_weight[index] = node.impurityStats().count() #weighted count of element trough this node
self.node_sample_weight[index] = sum([e for e in node.impurityStats().stats()]) #weighted count of element trough this node
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please explain why this is the correct way to do things? I am not deeply familiar with this code.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You cam find the answer above.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is because

 node.impurityStats().count()

rounds the values in PySpark models, so it return zero values when it was not zero values

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you can please merge this PR. Thanks.


if node.subtreeDepth() == 0:
return index
Expand Down