Specificity in scikit learn

后端 未结 4 1191
遇见更好的自我
遇见更好的自我 2021-02-04 05:19

I need specificity for my classification which is defined as : TN/(TN+FP)

I am writing a custom scorer function :

from sklearn.         


        
4条回答
  •  心在旅途
    2021-02-04 05:46

    Remembering that in binary classification, recall of the positive class is also known as “sensitivity”; recall of the negative class is “specificity”, I use this:

    unique, counts = np.unique(y_test, return_counts=True)
    
    for i in unique:
        score = precision_score(y_true, y_pred, labels=unique, pos_label=i)
        print('score ' + str(i) + '  ' + str(score))
    

提交回复
热议问题