Tuesday, February 9, 2016

[Data Mining] ROC Curve

Receiver operating characteristic

https://en.wikipedia.org/wiki/Receiver_operating_characteristic
ROC : is for evaluating the binary classification models. 
EX :  in the Nearest neighbor search algo, when we difine different distance for the neighbors : distance < 50 is my neighbor VS distance<100 is my neighbor, we need ROC to tell which choice is better. 

How to make a ROC curve? 
for example, I have defined some rules for the neighbor and we have the result of 20 observations : 

individuscoreclasse
11+
20.95+
30.9+
40.85-
50.8+
60.75-
70.7-
80.65+
90.6-
100.55-
110.5-
120.45+
130.4-
140.35-
150.3-
160.25-
170.2-
180.15-
190.1-
200.05-
we will calcule 20 points : 
1 : we predict individu<=1  is +, the others are - : 
reality
+-
predictions
+10
-514
total614
so we get TPR = TP/P = 1/6 = 0.166; FPR = FP/F = 0/14 = 0
 --> the first point(0.166,0)

2 : we predict individu<=2  is +, the others are - : 
reality
+-
predictions
+20
-414
total614
so we get TPR = TP/P = 2/6 = 0.333; FPR = FP/F = 0/14 = 0
 --> the second point(0.333,0)
......

15 : we predict individu<=2  is +, the others are - : 
reality
+-
predictions
+69
-05
total614
so we get TPR = TP/P = 1; FPR = FP/F = 9/14 = 0.643
 --> the fifth point(1,0.643)
......

so we can have a curve like : 
the line x=y (0.5 ) means we cannot make decision with this prediction.
so , the surface bigger the better the model is. 
the surface names : AUC
if we have several model to compare : we should choose the one with biggest AUC.


No comments:

Post a Comment