New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
【PaddlePaddle Hackathon 2】3、为 Paddle 新增 corrcoef(皮尔逊积矩相关系数) #4316
Changes from 4 commits
828b3a3
e94096d
7255d78
a4a4b92
b2a9478
d70c75b
711cd66
5121887
eee4f64
ee93660
c901e1a
084779d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
.. _cn_api_linalg_corrcoef: | ||
|
||
corrcoef | ||
------------------------------- | ||
|
||
.. py:function:: paddle.linalg.corrcoef(x, rowvar=True, ddof=False, name=None) | ||
|
||
|
||
给定输入Tensor,计算输入Tensor的皮尔逊积矩相关系数矩阵。 | ||
细节请参考cov文档. 皮尔逊积矩相关系数 `R`和 协方差矩阵`C`的关系如下: | ||
|
||
.. math:: R_{ij} = \\frac{ C_{ij} } { \\sqrt{ C_{ii} * C_{jj} } } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 显示还是不对,把 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
好的好的 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Done! |
||
|
||
`R`的值在-1到1之间. | ||
|
||
参数: | ||
::::::::: | ||
- **x** (Tensor) - 一个N(N<=2)维矩阵,包含多个变量。默认矩阵的每行是一个观测变量,由参数rowvar设置。 | ||
- **rowvar** (bool, 可选) - 若是True,则每行作为一个观测变量;若是False,则每列作为一个观测变量。默认True。 | ||
- **ddof** (bool, 可选) - 在计算中不起作用,不需要。默认False。 | ||
- **name** (str, 可选) - 具体用法请参见 :ref:`api_guide_Name` ,一般无需设置,默认值为None。 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
返回: | ||
::::::::: | ||
- Tensor, 输入x的皮尔逊积矩相关系数矩阵。 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
代码示例: | ||
:::::::::: | ||
|
||
.. code-block:: python | ||
|
||
import paddle | ||
|
||
xt = paddle.rand((3,4)) | ||
paddle.linalg.corrcoef(xt) | ||
|
||
''' | ||
Tensor(shape=[3, 3], dtype=float32, place=Place(cpu), stop_gradient=True, | ||
[[ 1. , -0.73702252, 0.66228950], | ||
[-0.73702258, 1. , -0.77104872], | ||
[ 0.66228974, -0.77104825, 1. ]]) | ||
''' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.