Understanding Confusion Matrix

在这里插入图片描述

当我们获得数据时,在数据清理,预处理和争论之后,我们要做的第一步是将其提供给一个出色的模型,当然,还要获得概率输出。 但坚持下去! 我们如何能够衡量模型的有效性。 更好的效果,更好的性能,这正是我们想要的。 而这正是混乱矩阵引人注目的地方。 混淆矩阵是机器学习分类的性能测量。

  • 这个博客旨在回答以下问题:

1,混淆矩阵是什么以及为什么需要它?
2,如何计算2类分类问题的混淆矩阵?
今天,让我们一劳永逸地理解混淆矩阵。

  • What is Confusion Matrix and why you need it?

它是机器学习分类问题的性能测量,其中输出可以是两个或更多类。 它是一个包含预测值和实际值的4种不同组合的表。
在这里插入图片描述

它对于测量回忆,精度,特异性,准确性以及最重要的AUC-ROC曲线非常有用。

让我们从怀孕类比的角度理解TP,FP,FN,TN。
在这里插入图片描述

  • True Positive:

Interpretation: You predicted positive and it’s true.

You predicted that a woman is pregnant and she actually is.
(解释:你预测的是积极的,这是真的。

你预测一个女人怀孕了,她确实怀孕了。)

  • True Negative:

Interpretation: You predicted negative and it’s true.

You predicted that a man is not pregnant and he actually is not.
(解释:你预测消极,这是真的。

你预测一个男人没有怀孕,他实际上不是。)

  • False Positive: (Type 1 Error)

Interpretation: You predicted positive and it’s false.

You predicted that a man is pregnant but he actually is not.

(解释:你预测是积极的,这是假的。

你预测一个男人怀孕但实际上并非如此。)

  • False Negative: (Type 2 Error)

Interpretation: You predicted negative and it’s false.

You predicted that a woman is not pregnant but she actually is.

Just Remember, We describe predicted values as Positive and Negative and actual values as True and False.
(解释:你预测为负面而且是假的。

你预测一个女人没有怀孕,但实际上她是。

请记住,我们将预测值描述为正值和负值,将实际值描述为True和False。)
在这里插入图片描述

  • How to Calculate Confusion Matrix for a 2-class classification problem?

在这里插入图片描述

在这里插入图片描述
Let’s understand confusion matrix through math
Recall
在这里插入图片描述

Out of all the positive classes, how much we predicted correctly. It should be high as possible.

  • Precision
    在这里插入图片描述

Out of all the classes, how much we predicted correctly. It should be high as possible.

  • F-measure
    在这里插入图片描述

It is difficult to compare two models with low precision and high recall or vice versa. So to make them comparable, we use F-Score. F-score helps to measure Recall and Precision at the same time. It uses Harmonic Mean in place of Arithmetic Mean by punishing the extreme values more.
很难比较两种低精度和高召回率的模型,反之亦然。 因此,为了使它们具有可比性,我们使用F-Score。 F-score有助于同时测量Recall和Precision。 它通过惩罚极值来使用调和均值代替算术平均值。

猜你喜欢

转载自blog.csdn.net/weixin_41697507/article/details/88710760