Improving the Interpretability of SHAP Plots

Sergey Korolev7 Jun 2024

Problem

A product analyst at VK wants to know which factors the team can influence move the target metrics of communities. He trains an ML model to find out. The standard SHAP summary_plot ranks features, but it cannot show which category values matter, which absolute values of a numeric feature are "high", how many objects have each value, or whether some features dominate the others. Without these answers, the findings are hard to turn into a product decision or to explain to managers.

Example from the article: a CatBoost classifier on the Titanic survival data, where the summary plot shows that sex and class matter most but not which values push survival up or down.

Solution in brief

Replace the single summary plot with one grid of SHAP dependence plots, one per feature, ordered by importance and titled with each feature's share of total importance. Semi-transparent points show how often values occur. Rules for cutting outliers, rare categories and the least accurate predictions keep each subplot readable. One function builds the whole figure.

Questions this case answers
  • How to turn a tree model's attributions into per-feature effect curves that show thresholds and data density when features are heavy-tailed or have many rare categories
  • How to present feature importance and feature-value effects to non-technical stakeholders in one figure
  • How to see which values of a product factor raise or lower a target metric when a tree model has been trained on it?
  • How to show SHAP importance and the effect of each feature value on a single readable figure?

Tools and methods

  • SHAP (TreeExplainer, dependence_plot) — per-feature plots of SHAP value against feature value
  • CatBoost — the tree model that is explained
  • Matplotlib — grid layout, zero line, grid and saving
Continue reading — it's free

Google or a one-time email code. No password.