Photo by Priscilla Du Preez on Unsplash

Member-only story

SHAP: Explain Any Machine Learning Model in Python

Your Comprehensive Guide to SHAP, TreeSHAP, and DeepSHAP

Louis Chan
TDS Archive
Published in
13 min readJan 11, 2023

Motivation

Story Time!

Imagine you have trained a machine learning model to predict the default risk of mortgage applicants. All is good, and the performance is excellent too. But how does the model work? How does the model come to the predicted value?

We stood there and said that the model considers several variables and the multi-dimensional relationship and pattern are too complex to be explained in plain words.

That’s where model explainability could save the day. Among the algorithms that can dissect machine learning models, SHAP is one of the more agnostic players in the field. In this blog, we will dive deep into the following items:

  • What are Shapley values?
  • How to calculate them?
  • How to use it in Python?
  • How does SHAP support local and global explanability?
  • What visualizations are available in the SHAP library?
  • How do the common variants of SHAP work? — TreeSHAP & DeepSHAP
  • How does LIME compare against SHAP?

Shapley Values

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

TDS Archive
TDS Archive

Published in TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Louis Chan
Louis Chan

Written by Louis Chan

Learn from your own mistakes today makes you a better person tomorrow.

Responses (3)

Write a response