-
Notifications
You must be signed in to change notification settings - Fork 40
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
Update Probatus to use the latest version of SHAP #225
Comments
I am trying to solve this one for fun. Seems it won't be so simple. I am testing it with python3.11 and I am getting errors with tests
|
With versions
so the trouble will be with new release of shape. I know there was some initiative about resurrecting the project. I will check later today what is the most likely issue in |
Seems like the only import is from shap import Explainer
from shap.explainers._tree import Tree
from shap.utils import sample
from sklearn.pipeline import Pipeline at https://github.com/ing-bank/probatus/blob/main/probatus/utils/shap_helpers.py#L25 |
Okay so in X = pd.DataFrame(
{
"col_1": [1, 0, 1, 0, 1, 0, 1, 0],
"col_2": [0, 0, 0, 0, 0, 1, 1, 1],
"col_3": [1, 1, 1, 0, 0, 0, 0, 0],
}
)
y = pd.Series([0, 0, 0, 0, 1, 1, 1, 1]) both "col_2" and "col_3" seems to be valid options, so this is more issue of designed test. It is a bit unfair that random seed in this version of shape is not preserved with results. |
The same is for |
Amazing work, looking forward to review your pr |
I am not sure how much time I will have today for this issue. Apparently, it is not caused by scikit-lean. I have tried 1.2.0 and I am still getting fail on those errors. |
It won't be numba, version 0.57.0 gives still error in pytest. When switching back to shap==0.41.0 it gives me a lot of jit errors even tho I have numba==0.57.1 |
Okay, so all tests are passing with
the rest can be updated. You know that shap had fixed dependency of numpy<=1.23.5, so I am pretty confident it was caused solely by shap release. |
Looking at changes in |
Inspecting shap codebase I don't see any relevant change in logic of _kernel.py, _linear.py or _tree.py between tag v0.42.1 and v0.41.0. I will look whether there are any changes in output of |
I can confirm now that the logic on the side of shap package changes and that is the reason why the tests are failing! shap_values = shap_calc(clf, X_val, verbose=self.verbose, **shap_kwargs)
print(shap_values.shape)
print(shap_values) With shap==0.41.0
With shap==0.42.1
|
Looking at https://github.com/ing-bank/probatus/blob/main/probatus/utils/shap_helpers.py#L200 I now understand what is the source of error on the side of probatus
The new version of shap will return
Looking at those shap values, I don't see anything wrong with it. I will need to dig deeper on the side of shap. @ReinierKoops If you want to have a look at my so far findings, or maybe you have similar experience with shap in past. |
@detrin Ive been reading along with your findings and confirm your thorough approach. Thank you. I’m a bit puzzled now by the versioning of shap making me question it’s backward compatibility… other than that now I’m also thinking along what the next step would be in this case. |
I think the best for the sale of this package would be find the cause on the side of shap package.
|
After additional 40 min of debugging and digging in shap and probatus I found the error. The issue is not preserved random_state in My suggestion for fix would be to correct failing tests as now we can be sure that the logic of shap didn't change and this change in calculated masker should not affect the quality of a result on probatus side. @ReinierKoops |
Amazing find, thank you @detrin |
@ReinierKoops No problem, I enjoyed this issue. The question now is whether you would like me to temp fix the tests or wait for the fix in shap or something else. |
I think best way is to introduce a temp fix for now. We don’t know when shap will be fixed. |
Awesome, you can expect from me PR in following days, probably today. |
#225 Also fixed one test for numpy>=1.24.0.
Perfect, thanks! |
Right now we are using an outdated version of SHAP. Given the sudden release of some updates a few weeks ago for SHAP, it is now possible to fix issues with SHAP by updating it in Probatus:
The text was updated successfully, but these errors were encountered: