SHAP (SHapley Additive exPlanations)
SHAP (SHapley Additive exPlanations)
Introduction
-
black box모델의 예측결과를 설명하기 위한 method
-
SHAP은 게임 이론 중 Shapley Values의 개념에 기초해서 만들어짐
-
shapley values는 협력 게임 이론(coalitional game theory)으로 도출된 개념으로 각 player들의 협력과 비협력에 따른 영향을 계산해 payout을 align하는 개념임
-
SHAP 의 두가지 접근 방법
-
local surrogate
-
Kernel SHAP
-
Tree SHAP
-
global interpretation
-
Shapley values를 aggregation하여 해석하는 방법
Definition
-
SHAP은 게임 이론에서 나온 Shapely values를 계산하여 얻음
-
SHAP은 Feature들을 넣었다 빼었다하는 dataset을 구성하고, 이를 linear model을 구성하고, 구성된 linear model의 coefficient (가중치)를 가지고 해석함
-
LIME과 Shapley values와 밀접한 관계를 가짐
-
model은 tabular, image에서 주로 사용
-
coalition vector를 구성하는 것이 중요
-
Local accuracy
-
Shapley efficiency
-
Missingness
-
missing feature는 0로 표현 됨
-
Consistency
-
feature의 증감에 따라 Shapley values도 증가하거나 변하지 않음
Kernel SHAP
-
5 steps
-
feature 조합 생성 → random coalition 생성
-
각 feature들의 조합을 model에 태워 결과 얻음
-
각 feature 조합들의 weight 계산
-
weighted 매겨진 data를 이용해 linear model을 만듦
-
만들어진 linear model을 이용하여 shapley values를 계산
-
hx(z)를 이용해 feature coalition 조합을 생성
-
이미지의 경우는 super pixel 별로 껐다 켰다 하면서 dataset 만듦 (LIME과 유사)
-
Kernel SHAP의 경우, 추정된 값들이 실제 instance보다 높은 weight를 가지게 되는 문제점이 있어 결과에 대한 신뢰도가 낮음
-
LIME vs Kernel SHAP
-
LIME과의 가장 큰 차이는 data에 weight를 매기는 방식
-
LIME의 경우, instance와의 거리를 통해 weight를 매김 (가까울수록 높은 weight, exponential)
-
Kernel SHAP의 경우, Shapley values 의 추정 값에 따라 weight가 매겨짐
-
Kernel SHAP 모델 학습 방법
-
만든 dataset을 가지고 linear model을 학습함
Tree SHAP (내용 보완 필요)
-
Tree 기반의 ML model 해석을 위한 알고리즘
-
decision tree, random forest, gradient boosting tree 등
-
기존의 kernel SHAP에 비해 분석 속도가 더 빠름
Example
-
각 사람이 암에 걸릴 확률을 예측한 결과에 대한 설명을 나타낸 그림이다
SHAP Feature Importance
-
SHAP은 local영역에서의 예측 결과를 설명하는 LIME과는 달리, global importance를 계산함
-
각 local 영역에서 얻은 가중치를 평균내는 방식
-
shapley value의 절대값의 평균을 구함
-
global importance를 구한다는 점에서 SHAP feature importance는 permutation feature importance의 대안으로 쓸 수 있음
-
permutation feature importance : feature의 value를 변화시키면서 model의 결과를 보고 변하는 정도로 importance를 측정하는 기법
-
위 permutation 방식과는 달리 SHAP은 여러 조합에 대해 종합적으로 평균을 내어서 Feature importance를 구함
SHAP Summary Plot
-
SHAP summary plot은 feature의 value의 변화에 따라 해당 featue가 어느정도의 중요성을 갖는지를 판단할 수 있음
SHAP Dependence Plot
-
SHAP feature depence plot은 feature value 에 대한 shape value를 확인하는 용도로 쓸 수 있음
SHAP Interaction Values
-
Shapely interaction index
-
해당 feature와 다른 feature 간의 상호 의존성에 대해 확인할 수 있음
Clustering SHAP values
-
feature 끼리 clustering을 함 → 이를 통해 각 데이터들이 model의 결과에 어떤 영향을 미치는 지 알 수 있음
-
x 축 데이터 instance, red : 긍정적 영향 (shap value 증가), blue:red : 부정적 영향 (shap value 감소)
Advantage
-
게임이론에서 비롯된 유일의 이론적인 방법
-
feature values의 공정한 분배를 통해 예측 결과를 평가함
-
SHAP은 LIME과 Shapley values와 연결되어 있어 두가지 방법을 이해하는데 도움이 됨
-
SHAP 은 Tree기반 모델에 대해 빠른 설명력을 가질 수 있음
-
global model interpretations
Disdvantage
-
Kernel SHAP은 일단 느림
-
Kernel SHAP은 Feature 간의 종속성을 무시함
-
Tree SHAP은 직관적이지 않은 feature attribution을 생산함
출처
-
Lundberg, Scott M., and Su-In Lee. "A unified approach to interpreting model predictions." Advances in Neural Information Processing Systems. 2017.↩
-
Lundberg, Scott M., Gabriel G. Erion, and Su-In Lee. "Consistent individualized feature attribution for tree ensembles." arXiv preprint arXiv:1802.03888 (2018).↩
-
Sundararajan, Mukund, and Amir Najmi. "The many Shapley values for model explanation." arXiv preprint arXiv:1908.08474 (2019).↩
-
Janzing, Dominik, Lenon Minorics, and Patrick Blöbaum. "Feature relevance quantification in explainable AI: A causality problem." arXiv preprint arXiv:1910.13413 (2019).
-
https://christophm.github.io/interpretable-ml-book/shap.html#fnref44