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 shap_values compatibility with shap>=0.43.0 by adjusting check_additivity parameter handling for TreeExplainer #872

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions econml/_shap.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

"""

import inspect
import shap
from collections import defaultdict
import numpy as np
Expand Down Expand Up @@ -161,7 +162,7 @@ def _shap_explain_model_cate(cme_model, models, X, d_t, d_y, featurizer=None, fe
output_names=output_names_,
input_names=input_names_,
background_samples=background_samples)
if explainer.__class__.__name__ == "Tree":
if "check_additivity" in inspect.signature(explainer).parameters:
shap_out = explainer(F, check_additivity=False)
else:
shap_out = explainer(F)
Expand Down Expand Up @@ -340,7 +341,7 @@ def _shap_explain_multitask_model_cate(cme_model, multitask_model_cate, X, d_t,
input_names=input_names_,
background_samples=background_samples)

if explainer.__class__.__name__ == "Tree":
if "check_additivity" in inspect.signature(explainer).parameters:
shap_out = explainer(F, check_additivity=False)
else:
shap_out = explainer(F)
Expand Down
Loading