I m not sure how or why, but my python code is converting the matrix I enter to a 3-D array. I simply want to find the covariance of a matrix (or a within-class scatter matrix) using this code :
enter code here
import numpy as np
import scipy.stats.stats as sss
class1 = np.loadtxt('class.txt')
col = np.loadtxt('col.txt')
print(class1)
idx = np.where(class1==1)
print(idx)
Nin = col[idx,:]
print(Nin)
idx2 = np.where(class1==0)
Nac= col[idx2,:]
NacT = np.transpose(Nac)
Scatter = np.dot(NacT,Nac)
ScatterAC = np.divide(Scatter)
enter code here
The error I get is:
ValueError: shapes (739,8903,1) and (1,8903,739) not aligned: 1 (dim 2) != 8903 (dim 1)
I am not sure what is the problem? Can someone help?