Created
January 11, 2021 08:08
-
-
Save roma-glushko/20d7bb27d5249f43ce647fdd402c6c5f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import shap | |
shap.initjs() | |
# Create object that can calculate shap values | |
explainer = shap.TreeExplainer(rf_classifier) | |
# Calculate Shap values | |
shap_values = explainer.shap_values(X_test, y_test) | |
# show feature importance for 0 class | |
shap.summary_plot(shap_values[0], X_test_transformed) | |
# show decision path for 30th example and 2nd class | |
shap.decision_plot(explainer.expected_value[2], shap_values[2][30, :], X_test_transformed.iloc[30, :]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment