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

BUG: AttributeError for Interaction Values with RandomForestClassifier #3323

Closed
4 tasks done
CloseChoice opened this issue Oct 9, 2023 · 0 comments · Fixed by #3364
Closed
4 tasks done

BUG: AttributeError for Interaction Values with RandomForestClassifier #3323

CloseChoice opened this issue Oct 9, 2023 · 0 comments · Fixed by #3364
Labels
bug Indicates an unexpected problem or unintended behaviour

Comments

@CloseChoice
Copy link
Collaborator

CloseChoice commented Oct 9, 2023

Issue Description

When calculating the interaction values for the RandomForestClassifier one runs into an AttributeError.

Minimal Reproducible Example

import shap
from sklearn.ensemble import RandomForestClassifier

from shap.explainers import TreeExplainer

X, y = shap.datasets.adult(n_points=50)
rfc = RandomForestClassifier(max_depth=1).fit(X, y)
ex_rfc = TreeExplainer(rfc)
e_rfc = ex_rfc(X, interactions=True)

Traceback

Traceback (most recent call last):
  File "/home/tobias/programming/github/shap/bugs/bug_report.py", line 16, in <module>
    e_rfc = ex_rfc(X, interactions=True)
  File "/home/tobias/programming/github/shap/shap/explainers/_tree.py", line 244, in __call__
    ev_tiled = np.tile(self.expected_value, (v.shape[0], 1))
AttributeError: 'list' object has no attribute 'shape'

Expected Behavior

Output should be consistent with output of XGBoost, CatBoost, etc. See this issue for further discussion on consistency.

Bug report checklist

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest release of shap.
  • I have confirmed this bug exists on the master branch of shap.
  • I'd be interested in making a PR to fix this bug

Installed Versions

shap-0.43.0

@CloseChoice CloseChoice added the bug Indicates an unexpected problem or unintended behaviour label Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behaviour
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant