矩阵输出看起来转置了

矩阵输出看起来转置了

本文介绍了为什么我的 sklearn.metrics 混淆_矩阵输出看起来转置了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我的理解是混淆矩阵应该在列中显示 TRUE 类,在行中显示 PREDICTED 类.因此,列的总和应该等于 TRUE 系列的 value_counts().

It's my understanding that confusion matrices should show the TRUE classes in the columns and the PREDICTED classes in the rows. Therefore the sum of the columns should be equal to the value_counts() of the TRUE series.

我在这里提供了一个例子:

I have provided an example here:

from sklearn.metrics import confusion_matrix

pred = [0, 0, 0, 1]
true = [1, 1, 1, 1]

confusion_matrix(true, pred)

为什么这会给我以下输出?当然应该是那个的转置?

Why does this give me the following output? Surely it should be the transpose of that?

array([[0, 0],
       [3, 1]], dtype=int64)

推荐答案

混淆可能是因为 sklearn 遵循与维基百科文章不同的混淆轴约定.所以,回答您的问题:它以特定格式为您提供输出,因为 sklearn 期望您以特定方式阅读它.

The confusion probably arises because sklearn follows a different convention for axes of confusion matrix than the wikipedia article. So, to answer your question: It gives you the output in that specific format because sklearn expects you to read it in a specific way.

以下是两种不同的混淆矩阵的书写方式:

Here are the two different ways of writing confusion matrix:

这篇关于为什么我的 sklearn.metrics 混淆_矩阵输出看起来转置了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 21:59