PCA:主成分分析-Python实现,X:[2500,784],把X降到50维

 1 def pca(X=np.array([]), no_dims=50):
 2     """
 3         Runs PCA on the NxD array X in order to reduce its dimensionality to
 4         no_dims dimensions.
 5     """
 6 
 7     print("Preprocessing the data using PCA...")
 8     (n, d) = X.shape
 9     X = X - np.tile(np.mean(X, 0), (n, 1)) # np.mean(X,0)在列上求均值
10     (l, M) = np.linalg.eig(np.dot(X.T, X))
11     Y = np.dot(X, M[:, 0:no_dims])
12     return Y
np.linalg.eig(np.dot(X.T, X)):
eig方法:
计算方阵的特征值和右特征向量。
l:(784,):特征值
M:(784,784):右特征向量
Y = X*M

补:

实现pca降维-Python实现

实现pca降维-Python实现

实现pca降维-Python实现

参考:

https://blog.csdn.net/baimafujinji/article/details/79407488

https://blog.csdn.net/qq_24464989/article/details/79834564?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase

 

 





相关文章:

  • 2019-11-13
  • 2021-07-28
  • 2021-11-20
  • 2021-12-02
  • 2021-11-09
  • 2021-06-20
  • 2022-12-23
猜你喜欢
  • 2021-11-30
  • 2022-12-23
  • 2021-07-06
  • 2022-12-23
  • 2021-12-29
  • 2021-11-30
  • 2022-01-28
相关资源
相似解决方案