如何解决为什么用公式计算DICE系数?
我尝试理解以下骰子系数公式的概念。我想将此公式应用于两个二进制图像
def single_dice_coef(y_true,y_pred_bin):
# shape of y_true and y_pred_bin: (height,width)
intersection = np.sum(y_true * y_pred_bin)
if (np.sum(y_true)==0) and (np.sum(y_pred_bin)==0):
return 1
return (2*intersection) / (np.sum(y_true) + np.sum(y_pred_bin))
我对实现骰子系数的想法是
def calculate_fitness(start_image,goal_image):
# The numer of correctly classified edge points
truePositive = 0
# The numer of incorrectly classified edge points
falsePositive = 0
# The number of edge points that should have been classified as edge points but were not
falseNegative = 0
weight,height = start_image.shape
for x_pixel in range(weight):
for y_pixel in range(height):
if start_image[x_pixel][y_pixel] == goal_image[x_pixel][y_pixel] == 1:
truePositive = truePositive + 1
if start_image[x_pixel][y_pixel] == 1 and goal_image[x_pixel][y_pixel] == 0:
falsePositive = falsePositive + 1
if start_image[x_pixel][y_pixel] == 0 and goal_image[x_pixel][y_pixel] == 1:
falseNegative = falseNegative + 1
return (2 * truePositive) / (2 * truePositive + falsePositive + falseNegative)
我不明白为什么在fisrt公式中我们不除以(2 * truePositive + falsePositive + falseNegative),而只是除以(np.sum(y_true)+ np.sum(y_pred_bin))
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。