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: SHAP doesn't work with PySpark loaded models #3383

Open
4 tasks done
mriomoreno opened this issue Nov 13, 2023 · 0 comments · May be fixed by #3384
Open
4 tasks done

BUG: SHAP doesn't work with PySpark loaded models #3383

mriomoreno opened this issue Nov 13, 2023 · 0 comments · May be fixed by #3384
Labels
bug Indicates an unexpected problem or unintended behaviour

Comments

@mriomoreno
Copy link

mriomoreno commented Nov 13, 2023

Issue Description

When you load a pyspark model and the you fit treeExplainer you get the following error:

AssertionError: The background dataset you provided does not cover all the leaves in the model, so TreeExplainer cannot run with the feature_perturbation=\"tree_path_dependent\" option! Try providing a larger background dataset, or using feature_perturbation=\"interventional\"

Minimal Reproducible Example

from pyspark.ml.classification import GBTClassificationModel
loaded_model = GBTClassificationModel.load("path_to_model")

import shap
explainer = shap.TreeExplainer(loaded_model )

explainer.shap_values(df)

Traceback

AssertionError: The background dataset you provided does not cover all the leaves in the model, so TreeExplainer cannot run with the feature_perturbation=\"tree_path_dependent\" option! Try providing a larger background dataset, or using feature_perturbation=\"interventional\"

Expected Behavior

#2700 This PR should fix the problem.

@CloseChoice, @thatlittleboy , @slundberg could anyone merge the PR?

Thanks!

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

latest

@mriomoreno mriomoreno added the bug Indicates an unexpected problem or unintended behaviour label Nov 13, 2023
@mriomoreno mriomoreno linked a pull request Nov 13, 2023 that will close this issue
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