confusion_matrix.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:mapillary_vistas 作者: mapillary 项目源码 文件源码
def calculate_confusion_matrix_from_arrays(prediction, ground_truth, nr_labels):
    """
    calculate the confusion matrix for one image pair.
    prediction and ground_truth have to have the same shape.
    """

    # a long 2xn array with each column being a pixel pair
    replace_indices = np.vstack((
        ground_truth.flatten(),
        prediction.flatten())
    ).T

    # add up confusion matrix
    confusion_matrix, _ = np.histogramdd(
        replace_indices,
        bins=(nr_labels, nr_labels),
        range=[(0, nr_labels), (0, nr_labels)]
    )
    confusion_matrix = confusion_matrix.astype(np.uint32)
    return confusion_matrix
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号