Skip to content

Instantly share code, notes, and snippets.

@rkdgusrn1212
Created May 30, 2022 14:50
Show Gist options
  • Save rkdgusrn1212/0678f0e93216bd538809c28fef787a7c to your computer and use it in GitHub Desktop.
Save rkdgusrn1212/0678f0e93216bd538809c28fef787a7c to your computer and use it in GitHub Desktop.
SHAP in python
import shap
#Tree, Deep or kernel
explainer = shap.TreeExplainer(my_model)
shap_values = explainer.shap_values(single_record)
shap.initjs()
shap.force_plot(explainer.expected_value[0], shap_values[0], single_record)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment