rank_correlation.py 文件源码

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

项目:MetaphoricChange 作者: Garrafao 项目源码 文件源码
def score_mod(gold, prediction, method):
    """
    Computes correlation coefficient for two lists of values.
    :param gold: list of gold values
    :param prediction: list of predicted values
    :param method: string, can be either of "pearson", "spearman" or "auc" (area under curve)
    :return: correlation coefficient and p-value
    """

    if len(gold) != len(prediction):
        raise ValueError("The two arrays must have the same length!")

    gold = np.array(gold, dtype=np.double)
    prediction = np.array(prediction, dtype=np.double)

    if method == "pearson":
        return pearson(gold, prediction)
    elif method == "spearman":
        return spearman(gold, prediction)
    elif method == "auc":
        return auc(gold, prediction)
    else:
        raise NotImplementedError("Unknown scoring measure:%s" % method)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号