-
-
Notifications
You must be signed in to change notification settings - Fork 236
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
Sort SHAP explanation charts #144
Conversation
@andreybavt To check what it's doing, you can check the demo projects: 1. Zillow price prediction - regression 2. German credit scoring - binary classification 5. ENRON - multi classification BEFORE AFTER |
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.
I left some minor comments, plus there are a few "Code smells" from Sonar. Let me know if you have time to finish this PR, otherwise, I can do it myself @alexcombessie
const explanationSumByFeature: object = {}; | ||
topFeatures.forEach((element, index) => { | ||
explanationSumByFeature[element] = explanationSum[index]; | ||
}); |
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.
simplification nitpick: explanationSum
auxiliary array (and some other aux variables) creation can be avoided if you replace lines 158-170 with something like this:
// Compute the sum of SHAP explanations by feature
const explanationSumByFeature: { [name: string]: number } = _.reduce(
_.values(this.fullExplanations),
(acc, labelExplanations) => {
_.forOwn(labelExplanations, (featureName, explainValue) => {
acc[explainValue] = (acc[explainValue] || 0) + featureName;
});
return acc;
}, {}
)
here I'm using lodash that you can import with import _ from "lodash";
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.
Sure, but I wonder if this version is not less readable? Also, are you 100% sure this is the same formula as the code I wrote? Just asking, since I spent over 3 hours to craft the formula and make sure it was correct.
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.
If I'm not missing anything, your transforming Category->feature->explanation
nested dictionary into feature->explanation
dictionary by summing up explanations by feature
across categories
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.
yep exactly, with sorting
Thanks! I took care of the code smells directly in 483a246 For the rest, I won't have time before next week. This afternoon I need to work on the EIC proposal, on which I am already quite late. So yeah if you can finish it, that would be fantastic, thanks! |
Kudos, SonarCloud Quality Gate passed! |
Kudos, SonarCloud Quality Gate passed! |
https://giskard.youtrack.cloud/issue/GSK-158