I don't understand the flow of the correlation matrix calculation.
#Create correlation matrix
R=np.corrcoef(X.T)
# set the diagonal component to zero
_R=R-np.identity(10)
# Get index with maximum correlation coefficient
index=np.where(_R==_R.max())[0]
I think the correlation matrix is calculated according to this flow, but why is the correlation matrix found when the diagonal component is set to zero and the maximum correlation coefficient is taken?
python machine-learning numpy mathematics
This source code is not looking for a correlation matrix.The correlation matrix itself is first determined by the np.corrcoef
function.
The non-diagonal component of the correlation matrix is the correlation coefficient between the two different data, but The diagonal component must be one.In the "Get Indexes with Maximum Correlation Coefficient" section, we are looking for an index that maximizes the correlation coefficient after excluding this diagonal component.
© 2024 OneMinuteCode. All rights reserved.