From this roc
function
How can I get the AUC(area under curve) value?
Here is the code i used:
def roc(data_set):
normal = 0
data_set_size = data_set.shape[1]
roc_rate = np.zeros((2, data_set_size))
for i in range(data_set_size):
if data_set[2][i] == 1:
normal += 1
abnormal = data_set_size - normal
max_dis = data_set[1].max()
for j in range(1000):
threshold = max_dis / 1000 * j
normal1 = 0
abnormal1 = 0
for k in range(data_set_size):
if data_set[1][k] > threshold and data_set[2][k] == 1:
normal1 += 1
if data_set[1][k] > threshold and data_set[2][k] == 2:
abnormal1 += 1
roc_rate[0][j] = normal1 / normal # true positive
roc_rate[1][j] = abnormal1 / abnormal # false positive
return roc_rate
and Accuracy of model is the ratio of AUC/TotalArea ? Right ??
Thanks in advance.