Efficient pairwise correlation for two matrices of features

后端 未结 2 650
天命终不由人
天命终不由人 2020-12-11 04:05

In Python I need to find the pairwise correlation between all features in a matrix A and all features in a matrix B. In particular, I am interestin

2条回答
  •  伪装坚强ぢ
    2020-12-11 04:43

    Adding on to the above answer from personal experience,

    p1 = N*np.dot(B.T,A)
    

    worked way faster for me when compared to

    p1 = N*np.einsum('ij,ik->kj',A,B)
    

    This was especially true when A and B are large dimensional matrices.

提交回复
热议问题