import scipy.stats x = [1, 2, 3, 4, 5, 6, 7, 8, 9] y = [2, 1, 2, 4.5, 7, 6.5, 6, 9, 9.5] pearson_corr = scipy.stats.spearmanr
可以通过运行 scipy.stats.spearmanr(X,Y)来获得Spearman系数得分。 这听起来可能很复杂特别是对于高维数据集。在这种情况下,最好在矩阵中可视化相关关系。
- Spearman秩相关系数检验:使用`scipy.stats.spearmanr()`函数进行Spearman秩相关系数检验。
# 运行函数 spearmans_rank_correlation(x, y)[0] # 0.90377360145618091 # 仅仅检查我们的结果,使用 Scipy 的 Spearman scipy.stats.spearmanr
API scipy.stats.spearmanr()API :https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.spearmanr.html
Python代码 from scipy.statsimport spearmanr data1, data2= ... corr, p= spearmanr(data1, data2) 更多信息 scipy.stats.spearmanr
from scipy.cluster import hierarchy as hc corr = np.round(scipy.stats.spearmanr(df_keep).correlation,
领取专属 10元无门槛券
手把手带您无忧上云