Python – Seaborn Pairplot Pearsons P统计
发布时间:2020-12-20 11:47:42 所属栏目:Python 来源:网络整理
导读:我一直在从事 python / seaborn / scipy.stats / matplotlib.pyplot等新手的数据分析工作. Seaborn Correlation Coefficient on PairGrid ?这个链接帮助我通过皮尔森R得分呈现我的变量之间的关系. 然而,由于Pearsons测试的输出也应具有p值以指示统计显着性,
我一直在从事
python / seaborn / scipy.stats / matplotlib.pyplot等新手的数据分析工作.
Seaborn Correlation Coefficient on PairGrid g = sns.pairplot(unoutlieddata,vars=['bia','DW','HW','jackson','girths'],kind="reg") def corrfunc(x,y,**kws): r,_ = sps.pearsonr(x,y) ax = plt.gca() ax.annotate("r = {:.2f}".format(r),xy=(.1,.9),xycoords=ax.transAxes) g.map(corrfunc) sns.plt.show() 显示的是我提供的链接格式的代码. 任何想法都是神奇的 问候 解决方法
不确定是否有人会看到这个,但在与知道更多的人交谈后,答案如下
码 import matplotlib.pyplot as plt import seaborn as sns from scipy.stats import pearsonr def corrfunc(x,**kws): (r,p) = pearsonr(x,y) ax = plt.gca() ax.annotate("r = {:.2f} ".format(r),xycoords=ax.transAxes) ax.annotate("p = {:.3f}".format(p),xy=(.4,xycoords=ax.transAxes) df = sns.load_dataset("iris") df = df[df["species"] == "setosa"] graph = sns.pairplot(df) graph.map(corrfunc) plt.show() 结果 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |