(決策分析思考)Decision Analytic Thinking

主要內容:

  1. 準確度評判標準的缺陷
  2. The Confusion Matrix
  3. 非均衡類別的問題
  4. Data-Analytic Thinking
  5. 分析框架:期望值
  6. 模型評判的基準(Baseline)

 

———————————————————————————————————————————————

 

(一)準確度評判標準的缺陷

 

  1.  
  2. 需要肯定的是準確度(plain accuracy)評判標準比較流行且計算方便
  3. 在一些實際的案例中,準確度評判的效果強差人意(過於簡單)

  • 容易受到非均衡類別的影響
簡單的例子:
例如有兩個類別的東西A 和 B ,他們的比例爲 A:B = 999:1 ,A 是positive ,B 是 Negative,只要我們預測所有的樣本都是Positive,那麼我們模型的準確率便可以達到99.9% 。(很顯然,這樣的準確率是沒有意義的,如果能準確預測出哪些是Negative 纔是我們的主要目標)

  • 均衡地對待 false Positives 和 false Negatives 【定義見(二)】    —> 涉及到Cost的問題
簡單的例子:
在癌症檢測中,我們需要有區別地對待誤診爲癌症【false Negatives】和誤診爲沒有癌症【false Positives】,很顯然兩者的代價相差巨大,如果僅僅用準確度度量會產生很嚴重的後果

 

(二)The Confusion Matrix


  • 定義:Confusion Matrix 是一個NxN的矩陣,矩陣的列標題是實際的類別,矩陣的行標題是預測的類別
【二維Confusion Matrix 的例子 】
The layout of a 2 × 2 confusion matrix showing the names of the correct predictions (main diagonal) and errors (off-diagonal) entries.

 

 p(ositives)

   n(egatives)  

    Y(es)    

      True positives        

     False positives          

N(o)

         False negatives          

True negatives


在Confusion Matrix 中,對角線爲正確預測的案例,非對角線則爲預測錯誤

其中False positives 爲 將 negative 的案例錯誤地歸結爲positives

其中False negatives 爲 將  positives 的案例錯誤地歸結爲negatives

 

(三)非均衡類別問題

 

現實中我們常常會遇到類別非均衡的例子(例如詐騙檢測、特定顧客的定位等等),簡單地說,我們有時需要關注那些“小概率”事件。

類別的非均衡導致我們分析的樣本成爲偏態分佈,而偏態會在很大程度上影響‘準確度評判標準’(之前的例子已經說明了其影響機制,‘準確度評判標準’會產生誤導)。在這樣的情況下,我們需要關於樣本數據的更多信息以進一步分析。

例子:

假設有模型A、B,作用於同一均衡類別的數據後得到如下結果

         

churn     

not churn     

Y

500

200

N

0

300

        

churn     

not churn     

Y

300

0

N

200

500

Confusion matrix of A

 Confusion matrix of B

 

兩個模型均正確分類了80%的數據,但是他們的表現卻截然不同,A模型偏向於將 False churn 、B模型偏向於False not churn

 

假如這兩個模型應用於非均衡類別樣本那麼他們的模型之間的準確率變化將非常大,如下圖所示

 

 

 

(四)Data-Analytic Thinking

 

我們將數據科學應用到實際問題中時,我們需要考慮,問題中什麼最爲重要,我們的目標是什麼等各種問題,而不僅僅是模型效果

 

例如下面的對話:

Analyst : Our model is good based on the mean-squared error

Boss : mean-squared error of what?

Analyst: the value of the target variable, which is the number of stars that a user would give as a rating for the movie

Boss : Why is the mean-squared-error on the predicted number of stars an appropriate metric for our recommendation problem? 

Boss : Is it meaningful ?

Boss  : Is there a better metric ?

 

在實際工作中,很多分析人士只會使用那些在學校課堂中學習到的度量方式,而沒有自己的思考,這點相當可悲。

 

(五)分析框架:期望值



思考下面的問題‘targeting Marketing’:

對每個客戶個體而言,他們對於刺激的反饋概率往往很低,一般1%或2%左右,如果我們選取50%爲決策閾值,那麼我們將會得到結論“沒有人會對刺激有反應”


如果改用期望值,我們可以得到

據此我們能做出較好的決策

 

 


 


 

二維情況下


利用條件概率



得到計算公式


注:

 

例子:

Confusion Matrix、


 

p    

n    

Y      

56   

7    

N     

5   

42   


Cost-Benefit Matrix

 計算過程:


T = 110

 

P = 61

N = 49

p(p) = 0.55

p(n) = 0.45

tp rate = 56/61 = 0.92

fp rate = 7/49 = 0.14

fn rate = 5/61 = 0.08

tn rate = 42/49 = 0.86

 

PS: 其他一些度量標準

  • The metrics Precision and Recall are often used, especially in text classification and information retrieval. Recall is the same as true positive rate, while precision is TP/(TP + FP), which is the accuracy over the cases predicted to be positive.





(六)模型評判的基準(Baseline)

 

  1. 最大化預測準確率往往不是一個合適的目標
  2. Classification 的 baseline 可以是 Majority Classifier
  3. 在較多的機器學習研究中決策樹樁(Decision Stump)往往是較好的基準
  4. 有的時候我們能利用領域知識在預測作爲基準

注:Decision Stump: a decision tree with only one internal node, the root nodemostinformativefeature


 

In real-world domains simplistic measures rarely capture what is actually important for the problem at hand, and often mislead. Instead, the data scientist should give careful thought to how the model will be used in practice and devise an appropriate metric.

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