问题标签 [pearson]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
r - R - How to select specific values
I'm working in healthcare and I need help on how to use R. I explain: I have a set of data like that:
Here are my objectives:
Here is my code so far (it's not the most efficient but it work):
So, so far I have my correlation in M and my p-values in N. I need help on how to show R2 ?
And second part how to make R only show me when R2>0.5 and p-values<0.05 for example ? I used this line :
To show me only when the pearson coefficent is more than 0.9 as a training. But it just make me a list of every values that are superior to 0.9 ... So I don't know between which and which column this coefficient come from. The best would be that it show me significant values in a table with the name of column so after I can easily identify them. The reason I want to do that is because by table is 570 by 570 so I can't look at every p-values to keep only the significant one.
I hope I was clear ! It's my first post here, tell me if I did any mistake !
Thanks for your help !
python - Python pandas 相关 corr() TypeError:无法将 ['pearson'] 与块值进行比较
我认为它应该返回一个 float = -1.00 但它会产生以下错误:
TypeError:无法将 ['pearson'] 与块值进行比较
在此先感谢您的帮助。
python - 你如何计算 Python 中 Pearson's r 的置信区间?
在 Python 中,我知道如何使用 计算 r 和相关的 p 值scipy.stats.pearsonr
,但我无法找到计算 r 置信区间的方法。这是怎么做到的?谢谢你的帮助 :)
python - 高效计算和存储相似度矩阵
对于课堂上的推荐系统项目,我目前正在尝试为包含大约 7000 个用户(行)和 4000 个电影(列)的数据集构建和存储基于项目的相似度矩阵。所以我有一个数据透视表,其中 UserID 作为索引,MovieID 作为列,评级作为值。可以想象,有很多 0 评级。
目前我正在使用 scipy 包中的 pearsonr 函数。我认为为了存储所有距离,我必须计算所有列之间的皮尔逊系数,并将它们存储在一个对称的电影电影矩阵中。到目前为止我的代码(如您所见,我是 Python/编码的新手):
好吧,正如你可以想象的那样,这需要很长时间,我很想知道如何更有效地做到这一点。我的第一个想法是利用矩阵是对称的。但我不知道怎么做。
我的想法是这样的:
然而,即使我能让这个工作,我担心这里的问题是两个 for 循环。我试图以某种方式使用地图或 lambda 方法,但无处可去。
知道如何改进这一点(可能很多)?
python - 打印皮尔逊相关残差值
我能够计算两个列表之间的皮尔逊相关性:
我想要 list1 的观察到的预期值的列表。请问有人知道如何扩展此代码以打印观察到的预期值吗?
鉴于此测试的说明:http: //docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.stats.pearsonr.html 我不确定是否可以使用此方法获得这些值,或者如果其他东西更适合?
编辑,我现在可以计算线性回归模型:
补充说明:
我假设一旦我按照好心的建议拟合了一个模型,我就会弄清楚如何使用 linregress 包来拟合残差。
但是,当我打电话时:
我可以看到那里没有任何类似于 .resid/.residuals 等的东西。有人能指出我下一步的正确方向吗?目的是计算 list1 的观察到的预期值列表(见上文?)
更正:
给我这个:
我假设是残差。非常感谢。
*******更正******
0.00075454346398073121 是斜率 (m),0.032064593825268217 是常数 (c)。
非常感谢。
matlab - 计算 Pearson 相关性,避免零值
我有一个稀疏矩阵A(m,n)
,n
变量和m
观察值在哪里。我想计算所有 n 个变量之间的 Pearson 相关性。
我有一些缺失的观察结果,例如,如果A(2,3)
不可用,则意味着我没有这样的观察结果,因此,例如,如果我需要计算第 3 列和第 4 列之间的相关性,我必须丢弃第 2 行,即使A(2,4)
是可用的。这就是通常计算 Pearson 相关性的方式。
相反,在 MATLAB 中,该函数会corrcoef()
考虑所有值,包括缺失值(被视为零)。有没有一种简单的方法可以避免这种情况?此处提供了一个非常类似的问题Pearson Correlation without using zero element in Matlab但提供了一个工作解决方案仅用于两个向量之间的比较,而不是用于通用矩阵A(m,n)
where n > 2
。
r - 报告 cor() 输出的唯一组合
我想报告(融化的)相关矩阵中的所有唯一值。
如果我做:
我会得到:
然而,有些行有效地报告了同样的事情VarA VarB = VarB VarA
,所以我真正想要的是:
甚至更好地作为奖励删除与自身相关的变量,所以我只得到:
python - 皮尔逊相关零值
我正在计算皮尔逊相关性。最后,我得到如下结果(correlation1)。我想知道为什么我的所有第二个系数都为 0.0 作为相关性的结果。有谁能解释一下吗?此外,我的相关代码运行缓慢。我怎样才能使它快速?
结果(样本):
(0.52543523179249552, 0.0), (0.52543905756911169, 0.0), (0.52544196572206603, 0.0), (0.52545010637443945, 0.0)...
输入:
speed1_list:
[113.0, 116.0, 120.0, 120.0, 117.0, 127.0, 124.0, 118.0, 124.0, 128.0, 128.0, 125.0, 112.0, 122.0, 125.0, 133.0, 128.0, 129.0, 126.0, 123.0, 120.0, 118.0, 114.0, 119.0, 129.0, 127.0, 128.0, 122.0, 120.0, 125.0, 119.0...]
speed2_list:
[125.0, 123.0, 120.0, 115.0, 124.0, 120.0, 120.0, 119.0, 119.0, 122.0, 121.0, 116.0, 116.0, 119.0, 116.0, 113.0, 113.0, 115.0, 120.0, 122.0, 122.0, 113.0, 118.0, 121.0, 120.0, 119.0, 116.0...]
相关性1:(0.52543523179249552, 0.0), (0.52543905756911169, 0.0), (0.52544196572206603, 0.0), (0.52545010637443945, 0.0)...