def findcorrelation(self, A, B, k):
'''
Construct k by k matrix of Pearson product-moment correlation
coefficients for every combination of two columns in A and B
:param: A : first NMF solution matrix
:param: B : second NMF solution matrix, of same dimensions as A
:param: k : number of columns in each matrix A and B
Return: numpy array of dimensions k by k, where array[a][b] is the
correlation between column 'a' of X and column 'b'
Usage:
Called by instability()
'''
corrmatrix = []
for a in range(k):
for b in range(k):
c = np.corrcoef(A[:, a], B[:, b])
corrmatrix.append(c[0][1])
return np.asarray(corrmatrix).reshape(k, k)
评论列表
文章目录