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 precision #42

Open
DCC-lzhy opened this issue Mar 23, 2021 · 0 comments
Open

about metric mistake, recall and precision #42

DCC-lzhy opened this issue Mar 23, 2021 · 0 comments

Comments

@DCC-lzhy
Copy link

https://github.com/Reagan1311/DABNet/blob/b8d62fe7f14ae4909a9e9aad1dd6e0ade98431cd/utils/metric.py#L43-L56
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, :])

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

1 participant