-
Notifications
You must be signed in to change notification settings - Fork 165
Open
Description
Efficient-Segmentation-Networks/utils/metric/metric.py
Lines 43 to 56 in 0f0c32e
| # 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]) |
| accuracy += self.M[i, i] / np.sum(self.M[i, :]) |
Metadata
Metadata
Assignees
Labels
No labels