-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Force_plot function with link=logit displays incorrect results for feature importance #1145
Comments
@slundberg I've seen some discussion on this topic in #238 and #29 |
Sorry have been getting back on top of things after being out sick. Great catch! But the right solution I think is to match the behavior of the JS version of the plot. In the JS version we leave the pixels in logit space, but then change the tick marks to reflect a non-linear progress of values from the logit. Will comment on the PR with more thoughts. |
Fixes #1145: Force_plot function with link=logit & matplotlib=True, displays incorrect results for feature importance
Description
Force_plot does not display correct feature importance in case of link=logit
Steps/Code to Reproduce
Expected Results
PosFeat1, PosFeat2 and NegFeat1 all have exactly the same shap value (either positive or negative).
Each feature is represented by same size effect in plot.
Difference in length of negative and positive effects should equal difference base value vs output value
Actual Results
PosFeat2 effect is smaller than PosFeat1 effect.
Sum PosFeat effect - NegFeat1 effect < Output value - Base value
Analysis
Logit function is not linear, therefore the calculation of the effect is dependent of the order (and base value) of the calculation.
Proposed solution
(Special case sum=0; use derivative of logistic: exp(shap) / (exp(shap) + 1)^2
This way identical shap values result in identical probability effects.
Base value and feature effects sum up to the output value.
The text was updated successfully, but these errors were encountered: