Model-Agnostic Methods - Partial Dependence Plot (PDP)&Individual Conditional Expectation (ICE)

一、作爲模型代理方法的第一節,先介紹模型代理方法的思路

從world捕捉data,用data訓練模型,再用可解釋性方法來對模型的結果給出解釋。把模型訓練和模型解釋分開,使得訓練模型不再侷限在擁有內在可解釋性的模型範圍內。

二、下面介紹第一種Partial Dependence Plot (PDP),部分依賴圖形。描述的是單個或兩個feature對模型outcome的邊際影響。

The partial function tells us for given value(s) of features S what the average marginal effect on the prediction is. In this formula, x(i)c are actual feature values from the dataset for the features in which we are not interested, and n is the number of instances in the dataset.

PDP的前提假設是C中的feature與S中的不相關。

對於分類問題,the partial dependence plot displays the probability for a certain class given different values for feature(s) in S. An easy way to deal with multiple classes is to draw one line or plot per class.對S中每個特徵的不同值展示不同的概率值,對於多分類,按類別劃分。

對於類別型變量, the partial dependence is very easy to calculate. For each of the categories, we get a PDP estimate by forcing all data instances to have the same category.嘗試用每個類別覆蓋所有instance,計算概率。

There are a number of R packages that implement PDPs. I used the iml package for the examples, but there is also pdp or DALEX. In Python you can use Skater.

這裏使用Skater來演示PDP的使用,詳情請看https://github.com/oracle/Skater,裏面有examples供參考。

三、Individual Conditional Expectation (ICE)

The partial dependence plot for the average effect of a feature is a global method because it does not focus on specific instances, but on an overall average. The equivalent to a PDP for individual data instances is called individual conditional expectation (ICE) plot.PDP只描述模型feature的平均影響,而不關注單個實例的,於是有了ICE,每個instance一行。A PDP is the average of the lines of an ICE plot.。

每個實例對應一條曲線

改進的ICE plot有:

Centered ICE Plot:Sometimes it can be hard to tell whether the ICE curves differ between individuals because they start at different predictions. A simple solution is to center the curves at a certain point in the feature and display only the difference in the prediction to this point.中心化曲線

Derivative ICE Plot:Another way to make it visually easier to spot heterogeneity is to look at the individual derivatives of the prediction function with respect to a feature. The resulting plot is called the derivative ICE plot (d-ICE). The derivatives of a function (or curve) tell you whether changes occur and in which direction they occur.太複雜,不實用。

目前沒有Python的包,有R的

ICE plots are implemented in the R packages iml (used for these examples), ICEbox, and pdp. Another R package that does something very similar to ICE is condvis.

值得注意的是PDP和ICE在特徵存在相關性時存在很大問題。When features interact with each other in a prediction model, the prediction cannot be expressed as the sum of the feature effects, because the effect of one feature depends on the value of the other feature. Aristotle’s predicate “The whole is greater than the sum of its parts” applies in the presence of interactions.

 

四、Accumulated Local Effects (ALE) Plot

可以是爲PDP的無偏替代且速度更快。

這裏不作介紹了

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章