knock95.py 文件源码

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

项目:100knock2016 作者: tmu-nlp 项目源码 文件源码
def getSpearmanr(infile):
    x_list = list()
    y_list = list()
    for i, line in enumerate(open(infile, 'r')):
        words = line.strip('\n').split('\t')
        x_list.append((i, float(words[2])))
        y_list.append((i, float(words[3])))
    x_list = sorted(x_list, key=lambda x:x[1])
    y_list = sorted(y_list, key=lambda x:x[1])
    x_list = sorted([(x, i) for i, (x, score) in enumerate(x_list)], key=lambda x: x[0])
    y_list = sorted([(y, i) for i, (y, score) in enumerate(y_list)], key=lambda x: x[0])
    x_list, y_list = np.array(x_list), np.array(y_list)
    rho, pval = spearmanr(x_list[:, 1], y_list[:, 1])
    return rho, pval
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号