Apr-08-2018, 05:28 PM
I need to do Principal Components (PC) Analysis of a Matrix (X). PC need to be chosen as V(:,end-1,end). May I ask what's mean by "PC is chosen as V(:,end-1,end)" and how to do PC?
I have found eigen value and vector for transpose of X multiple X (XTX), here is my code (using python(x,y) 2.10.7.0):
I have found eigen value and vector for transpose of X multiple X (XTX), here is my code (using python(x,y) 2.10.7.0):
import numpy as np X=np.matrix(Xtrain) print("X") print(X) XT=X.transpose() XTX=np.dot(X,XT) print('XTX') print(XTX) from numpy import linalg as LA w,v= LA.eig(XTX) print('eigen values ') print(w) print('eigen vector ') print(v) #PCA from sklearn.decomposition import PCA def pca2(XTX, pc_count = None): return PCA(n_components = 4).fit_transform(XTX)after running, "ImportError: No module named sklearn.decomposition" is shown. What's the reason? Many thanks for help.