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: summary_plot ignores plot_type for TreeExplainer #3622

Open
2 of 4 tasks
bhvieira opened this issue Apr 23, 2024 · 1 comment
Open
2 of 4 tasks

BUG: summary_plot ignores plot_type for TreeExplainer #3622

bhvieira opened this issue Apr 23, 2024 · 1 comment
Assignees
Labels
bug Indicates an unexpected problem or unintended behaviour

Comments

@bhvieira
Copy link

Issue Description

In the MWE below, I would expect summary_plot to return a bar plot per class (this was the old behavior). Instead, no matter the argument in plot_type, I always get the interaction dot-plot.

Minimal Reproducible Example

# train a multiclass lgm on random sklearn data
import sklearn
import sklearn.datasets
import sklearn.model_selection
import lightgbm as lgb
import shap

X, y = sklearn.datasets.make_classification(n_samples=100, n_features=20, n_informative=5, n_classes=3, random_state=0)
X_train, X_test, y_train, y_test = sklearn.model_selection.train_test_split(X, y, random_state=1)
gbm = lgb.LGBMClassifier()
gbm.fit(X_train, y_train)

# explain the model's predictions using SHAP
explainer = shap.Explainer(gbm)
shap_values = explainer(X_test)

# summary_plot

shap.summary_plot(shap_values, X_test, plot_type="bar") # wrong plot

shap.summary_plot(shap_values, X_test, plot_type="asdasd asd") # even gibberish works

Traceback

No response

Expected Behavior

When setting plot_type="bar" I would expect shap to return a bar plot, not a compact_dot. When using gibberish arguments, I would expect shap to error out.

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

[[package]]
name = "shap"
version = "0.45.0"
description = "A unified approach to explain the output of any machine learning model."
category = "main"
optional = false
python-versions = ">=3.9"

[[package]]
name = "lightgbm"
version = "4.3.0"
description = "LightGBM Python Package"
category = "main"
optional = false
python-versions = ">=3.6"

[metadata]
lock-version = "1.1"
python-versions = ">=3.10,<3.12"

@bhvieira bhvieira added the bug Indicates an unexpected problem or unintended behaviour label Apr 23, 2024
@bhvieira bhvieira changed the title BUG: summary_plot ignotes plot_type for TreeExplainer BUG: summary_plot ignores plot_type for TreeExplainer Apr 23, 2024
@CloseChoice
Copy link
Collaborator

Thanks for reporting and the MWE, will have a look.

@CloseChoice CloseChoice self-assigned this May 16, 2024
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

No branches or pull requests

2 participants