【发布时间】:2020-05-06 04:49:45
【问题描述】:
以下代码计算两个有序列表之间的 spearman 等级相关性:
from scipy.stats import spearmanr
a1 = [0, 1, 2, 3, 4]
b1 = [0, 1, 3, 2, 5]
print(spearmanr(a1,b1).correlation) # the result is 0.9
结果是 0.9。但是当我在不改变顺序的情况下表示向量时,相关性变为0.5:
a2 = ['ESR1', 'TBC1D9', 'SCUBE2', 'EVL', 'NAT2']
b2 = ['ESR1', 'TBC1D9', 'EVL', 'SCUBE2', 'CIRBP']
print(spearmanr(a2,b2).correlation) # the result is 0.5
我想知道为什么即使顺序相同,结果也会改变。
【问题讨论】:
标签: python scipy correlation