理解线性变换和降维

>>> import numpy as np
>>> a = np.random.randint(0,50,size=(3,9))
>>> a
array([[33,  6, 21, 25, 32, 35, 22, 22,  5],
       [19, 13, 45, 17,  1, 49, 15, 35,  5],
       [47, 15, 49, 32, 27, 30, 39, 33, 30]])
>>> b = np.eye(3)
>>> np.allclose(a[0].dot(np.linalg.pinv(a).dot(b)),b[0])
True
>>> np.allclose(a[1].dot(np.linalg.pinv(a).dot(b)),b[1])
True
>>> np.allclose(a[2].dot(np.linalg.pinv(a).dot(b)),b[2])
True
>>> a.dot(np.linalg.pinv(a).dot(b))
array([[  1.00000000e+00,  -1.73472348e-17,   2.63677968e-16],
       [ -6.10622664e-16,   1.00000000e+00,   1.80411242e-16],
       [ -1.66533454e-16,  -3.33066907e-16,   1.00000000e+00]])
>>> np.allclose(_,np.eye(3))
True

以上代码将a从(u1, u2, u3, u4, u5, u6, u7)张成空间映射到(v1, v2, v3)张成空间,实现了降维

你可能感兴趣的:(理解线性变换和降维)