How can I analyze a confusion matrix?

前端 未结 3 544
北恋
北恋 2021-01-19 05:04

When I print out scikit-learn\'s confusion matrix, I receive a very huge matrix. I want to analyze what are the true positives, true negatives etc. How can I do so? This is

3条回答
  •  庸人自扰
    2021-01-19 05:41

    IIUC, your question is undefined. "False positives", "true negatives" - these are terms that are defined only for binary classification. Read more about the definition of a confusion matrix.

    In this case, the confusion matrix is of dimension N X N. Each diagonal represents, for entry (i, i) the case where the prediction is i and the outcome is i too. Any other off-diagonal entry indicates some mistake where the prediction was i and the outcome is j. There is no meaning to "positive" and "negative in this case.

    You can find the diagnoal elements easily using np.diagonal, and, following that, it is easy to sum them. The sum of wrong cases is the sum of the matrix minus the sum of the diagonal.

提交回复
热议问题