Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About metric mistake, recall and precison #20

Open
DCC-lzhy opened this issue Mar 23, 2021 · 1 comment
Open

About metric mistake, recall and precison #20

DCC-lzhy opened this issue Mar 23, 2021 · 1 comment

Comments

@DCC-lzhy
Copy link

# Pii为预测正确的数量,Pij和Pji分别被解释为假正和假负,尽管两者都是假正与假负之和
def recall(self): # 预测为正确的像素中确认为正确像素的个数
recall = 0.0
for i in range(self.nclass):
recall += self.M[i, i] / np.sum(self.M[:, i])
return recall / self.nclass
def accuracy(self): # 分割正确的像素除以总像素
accuracy = 0.0
for i in range(self.nclass):
accuracy += self.M[i, i] / np.sum(self.M[i, :])
return accuracy / self.nclass

it's reverse.
` # 理解混淆矩阵生成的代码的关键,行为真实值,列为预测值
# Pii为预测正确的数量,Pij=FN, Pji=FP
# 每一列之和表示被预测为该类别的样本数量 = TP+FP, precision = TP/(TP+FP), 所有被预测为正类中真正正类的比例
# 每一行之和表示该类别的真实样本数量 = TP+FN, recall = TP/TP+FN , 所有正类中,被找出的正类的比例

def recall(self):
    recall = 0.0
    class_recall = []
    for i in range(self.nclass):
        recall_i = self.M[i, i] / np.sum(self.M[i, :])
        recall += recall_i
        class_recall.append(recall_i)
    return recall / self.nclass, class_recall

def accuracy(self):
    accuracy = 0.0
    class_accuracy = []
    for i in range(self.nclass):
        accuracy_i = self.M[i, i] / np.sum(self.M[:, i])
        accuracy += accuracy_i
        class_accuracy.append(accuracy_i)
    return accuracy / self.nclass, class_accuracy`

So, change

recall += self.M[i, i] / np.sum(self.M[:, i])
and
accuracy += self.M[i, i] / np.sum(self.M[i, :])

@pipi-hua
Copy link

@DCC-lzhy Yes, I think your analysis makes sense. But this project may still use mIoU, so this may be less noticed. And it should be called "precision" here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants