-
Notifications
You must be signed in to change notification settings - Fork 252
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
Make shap an extra dependency #376
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Codecov Report
@@ Coverage Diff @@
## master #376 +/- ##
==========================================
- Coverage 87.73% 87.59% -0.15%
==========================================
Files 56 56
Lines 7372 7376 +4
==========================================
- Hits 6468 6461 -7
- Misses 904 915 +11
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks okay but what if someone tries to import something from shap-dependent parts of library without shap being installed?
alibi/explainers/shap_wrappers.py
?
I think it will fail in quite an ugly way -> maybe worth to have some logic that do try ... except
in shap
imports that in case shap is not present raise a valid warning / information?
Good point, forgot to handle this completely as it would fail immediately on |
This PR is meant to (temporarily) make
shap
an optional dependency. The reason is because the build process ofshap
currently is not optimal and will result inRuntimeError
when packages have a different runtime dependency onnumpy
than the build dependency ofnumpy
used forshap
.Concretely,
shap
on linux is built with the latest available version ofnumpy
(currently1.20
), whilsttensorflow
has anumpy
pin of1.19.5
. This means thatpip install alibi
results in a broken installation asshap
is still built against1.20
. As far as I've looked, it is not possible to specify a different version ofnumpy
to buildshap
against in a "one-pass" install ofalibi
(e.g. ifnumpy
is not present, shap will be built against1.20
regardless, ifnumpy
is present it will be built against that version).As a result, this PR proposes installing
alibi
withshap
support in two steps:I have added the above instructions to the README as well as at the top of the shap-specific notebooks.
This workaround should be resolved once
shap
specifiesoldest-supported-numpy
as a build dependency instead. For more information see here: shap/shap#1802