相關系數


皮爾遜積矩相關系數,又稱“相關系數”,

取值范圍為[-1,1],r=0,沒有相關性。

-1:表示方向完全相反

1:表示方向相同,並且完全一樣

0:表示沒有相關性

 

函數簽名:

numpy.corrcoef(xy=Nonerowvar=Truebias=<no value>ddof=<no value>)

rowvar:True,表示每行代表一個變量,列中包含觀測值。否則,關系將被轉置:每列表示一個變量,而行包含觀測值。

 

參考:

https://www.osgeo.cn/numpy/reference/generated/numpy.corrcoef.html # 中文說明文檔

https://numpy.org/doc/stable/reference/generated/numpy.corrcoef.html  # 英文說明文檔

內容如下:

numpy.corrcoef
numpy.corrcoef(x, y=None, rowvar=True, bias=<no value>, ddof=<no value>)[source]
Return Pearson product-moment correlation coefficients.

Please refer to the documentation for cov for more detail. The relationship between the correlation coefficient matrix, R, and the covariance matrix, C, is

R_{ij} = { C_{ij} } / { sqrt{ C_{ii} * C_{jj} } }

Parameters
xarray_like
A 1-D or 2-D array containing multiple variables and observations. Each row of x represents a variable, and each column a single observation of all those variables. Also see rowvar below.

yarray_like, optional
An additional set of variables and observations. y has the same shape as x.

rowvarbool, optional
If rowvar is True (default), then each row represents a variable, with observations in the columns. Otherwise, the relationship is transposed: each column represents a variable, while the rows contain observations.

bias_NoValue, optional
Has no effect, do not use.

Deprecated since version 1.10.0.

ddof_NoValue, optional
Has no effect, do not use.

Deprecated since version 1.10.0.

Returns
Rndarray
The correlation coefficient matrix of the variables.

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM