Scikit-learn: How to obtain True Positive, True Negative, False Positive and False Negative

前端 未结 16 1225
一生所求
一生所求 2020-12-02 04:25

My problem:

I have a dataset which is a large JSON file. I read it and store it in the trainList variable.

Next, I pre-process

16条回答
  •  北海茫月
    2020-12-02 05:06

    You can obtain all of the parameters from the confusion matrix. The structure of the confusion matrix(which is 2X2 matrix) is as follows (assuming the first index is related to the positive label, and the rows are related to the true labels):

    TP|FN
    FP|TN
    

    So

    TP = cm[0][0]
    FN = cm[0][1]
    FP = cm[1][0]
    TN = cm[1][1]
    

    More details at https://en.wikipedia.org/wiki/Confusion_matrix

提交回复
热议问题