analysis.py 文件源码

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

项目:opyrant 作者: opyrant 项目源码 文件源码
def dprime(confusion_matrix):
    """
    Function takes in a 2x2 confusion matrix and returns the d-prime value for the predictions.

    d' = z(hit rate)-z(false alarm rate)

    http://en.wikipedia.org/wiki/D'
    """
    if max(confusion_matrix.shape) > 2:
        return False
    else:
        hit_rate = confusion_matrix[0, 0] / confusion_matrix[0, :].sum()
        fa_rate = confusion_matrix[1, 0] / confusion_matrix[1, :].sum()

        nudge = 0.0001
        if (hit_rate >= 1): hit_rate = 1 - nudge
        if (hit_rate <= 0): hit_rate = 0 + nudge
        if (fa_rate >= 1): fa_rate = 1 - nudge
        if (fa_rate <= 0): fa_rate = 0 + nudge

        dp = norm.ppf(hit_rate)-norm.ppf(fa_rate)
        return dp


# accuracy (% correct)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号