1. Transpose is useful for two-dimensional arrays and does not work for an array.
2. Understand the correspondence between feature values and feature vectors
a=np.array([[1 ,2, 3],[4, 5, 6],[7, 8, 9]])aOut[27]: array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])w,v = LA.eig(a)wOut[29]: array([ 1.61168440e+01, -1.11684397e+00, -1.30367773e-15])vOut[30]: array([[-0.23197069, -0.78583024, 0.40824829], [-0.52532209, -0.08675134, -0.81649658], [-0.8186735 , 0.61232756, 0.40824829]])aOut[31]: array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])#dot(a[:,:], v[:,i]) = w[i] * v[:,i]w[0]Out[33]: 16.116843969807043v[:,0]Out[34]: array([-0.23197069, -0.52532209, -0.8186735 ])w[0]*v[:,0]Out[35]: array([ -3.73863537, -8.46653421, -13.19443305])np.dot(a[:,:],v[:,0])Out[37]: array([ -3.73863537, -8.46653421, -13.19443305])aOut[38]: array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])v[:,0]Out[39]: array([-0.23197069, -0.52532209, -0.8186735 ])1*-0.23197069+2*-0.52532209+3*-0.8186735Out[40]: -3.738635374*-0.23197069+5*-0.52532209+6*-0.8186735Out[41]: -8.46653421v[:,0]Out[42]: array([-0.23197069, -0.52532209, -0.8186735 ])v[:,0].TOut[43]: array([-0.23197069, -0.52532209, -0.8186735 ])w[0]Out[44]: 16.116843969807043w[0]*v[:,0]Out[45]: array([ -3.73863537, -8.46653421, -13.19443305])aOut[46]: array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])a.TOut[47]: array([[1, 4, 7], [2, 5, 8], [3, 6, 9]])c = v[0]cOut[49]: array([-0.23197069, -0.78583024, 0.40824829])c.TOut[50]: array([-0.23197069, -0.78583024, 0.40824829])
aOut[55]: array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])a*v[:,0]Out[56]: array([[-0.23197069, -1.05064419, -2.4560205 ], [-0.92788275, -2.62661047, -4.912041 ], [-1.62379481, -4.20257675, -7.36806149]])v[:,0]Out[57]: array([-0.23197069, -0.52532209, -0.8186735 ])
y = a*v[:,0]yOut[59]: array([[-0.23197069, -1.05064419, -2.4560205 ], [-0.92788275, -2.62661047, -4.912041 ], [-1.62379481, -4.20257675, -7.36806149]])np.sum(y[0,:])Out[63]: -3.7386353719172973np.sum(y[1,:])Out[64]: -8.4665342116284013np.sum(y[2,:])Out[65]: -13.194433051339505
Numpy. linalg. EIG