如何分析混乱矩阵? [英] How can I analyze a confusion matrix?

查看:81
本文介绍了如何分析混乱矩阵?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我打印出scikit-learn的混淆矩阵时,我会收到一个非常大的矩阵.我想分析什么是真正的积极因素,真正的消极因素等.我该怎么做? 这就是我的困惑矩阵的样子.我希望对此有所了解.

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 how my confusion matrix looks like. I wish to understand this better.

[[4015  336    0 ...,    0    0    2]
 [ 228 2704    0 ...,    0    0    0]
 [   4    7   19 ...,    0    0    0]
 ..., 
 [   3    2    0 ...,    5    0    0]
 [   1    1    0 ...,    0    0    0]
 [  13    1    0 ...,    0    0   11]]

推荐答案

IIUC,您的问题不确定. 假阳性",真阴性"-这些术语仅针对二进制分类定义.详细了解混淆矩阵的定义.

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.

在这种情况下,混淆矩阵的尺寸为 N X N .对于条目(i,i),每个对角线表示预测为 i 且结果也为 i 的情况.其他任何非对角线输入均表示预测为 i 且结果为 j 时出现了一些错误.在这种情况下,正"和负"没有意义.

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.

您可以使用 np.diagonal ,然后,很容易将它们相加.错误情况的总和是矩阵的总和减去对角线的总和.

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.

这篇关于如何分析混乱矩阵?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆