ML

PDP vs. LIME vs. SHAP

sapziling 2022. 6. 6. 18:18

ML의 interpretability와 관련된 방법론 일단 정말 간략하게 이해한 것을 다음과 같이 정리함

 

일단 관심있는 독립변수 X, 종속변수 Y라 하자

 

- PDP : X에 따라서 Y의 값이 어떻게 변하는지 plot으로 확인한다. 

    - 내가 관심있는 변수~ 예측값 이걸 plot으로 보고 해석하는 것. 즉 중요도를 본다기 보다는 예측값의 변화를 읽어내는 점에서 차이가 있다. 

    - 그 예측값은 관심없는 변수들을 marginalize해서 알게 되는데, 관심없는 변수들을 실제로 넣었을때 (실제 pair 가 아니더라도)  + 관심있는 변수의 조합일때 예측값을 구하게 된다.

 

 

 

- lime vs shap 

   - 공통점은 global만 아니라 local interpretability 해석 가능. sample마다 그 중요도가 다를 수도 있으니

   - 복잡한 모델대신 surrogate model이 있다고 가정하는 것임.

      - input에 살짝 변화를 줬을때 output이 어떻게 변화 하냐.

 

- lime

   예를 들어 감성분석을 한다고 하면, 이 sentence가 hateful이냐 아니냐

   - ex. x =“ 저 사람은 나빠”

      - interepretable한 간단한 format x’ 로 바꾼다. (1,0,1,0)

      - x’주변의 (neighborhood) 값 z’ (1,0,0,0)를 샘플링한다.

      - z’ 를 다시 z로 치환한다. z = “저 사람은 나쁨”

      - Let f(x) = 감성분석 모델, g(z) = f(x)의 surrogate model

      - $$g(z') = w_g*z'$$

      - w_g가 LIME value (local)

      - data point를 여러개하면

      - $$\sum_i^n|w_{ig}|$$

         가 global importance

      - g 찾는 것은 아래와 같이 likelihood minimize

 

-  shap

    - lime 과의 차이점은 local model을 linear regression이 아닌 shapley value를 사용한다는 것

    - shapley value는 변수를 넣고 안넣고의 차이가 아니라, 실제 예측치와, 평균 예측치의 차이이다.(그러나 그 예측치는 변수를 넣고 안넣었을때의 조건부 expectation)

    - SHAP value is NOT  the difference between the prediction with and without a variable, rather it is a contribution of a variable to the difference between the actual prediction and the mean prediction.

 

Reference 및 수식:

Lundberg, A Unified Approach to Interpreting Model Predictions

https://christophm.github.io/interpretable-ml-book/pdp.html

https://towardsdatascience.com/idea-behind-lime-and-shap-b603d35d34eb