PCA协方差矩阵

时间:2020-03-01 10:16:28

标签: python numpy pca

我正在协方差矩阵(2308, 2308)上进行PCA分解,以找出特征向量/特征值。我在下面添加代码:

r_matrix = np.matrix(r_mean)
r_matrix.T
SR_matrix = (r_matrix.T * r_matrix) * (1/361) #covariance matrix
SR_matrixx = pd.DataFrame(SR_matrix) #dataframe
eig_vals, eig_vecs = np.linalg.eig(SR_matrix)

我收到以下错误:

  File "<ipython-input-488-5406aac4c7cd>", line 1, in <module>
    eig_vals, eig_vecs = np.linalg.eig(SR_matrixx)

  File "/Users/FabioMassimo/anaconda3/lib/python3.7/site-packages/numpy/linalg/linalg.py", line 1305, in eig
    _assertFinite(a)

  File "/Users/FabioMassimo/anaconda3/lib/python3.7/site-packages/numpy/linalg/linalg.py", line 217, in _assertFinite
    if not (isfinite(a).all()):

TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

有解决方案吗?

0 个答案:

没有答案