我使用以下代码计算特征向量和特征值。
mean, eigenvectors, eigenvalues = cv2.PCACompute2(data_pts, mean)
但为什么会出现以下错误?
AttributeError: module 'cv2' has no attribute 'PCACompute2'
虽然我已经使用 pip 安装了 opencv-contrib-python
,但错误仍然存在。
除了 PCACompute2 之外,还有什么方法可以找到特征值吗?
最佳答案
也许 numpy.linalg.eig是你要找的吗?假设您将输入作为方阵发送。
import numpy as np
eigenvalues, eigenvectors = np.linalg.eig(M)
您可能还想看看这个问题的答案:Do non-square matrices have eigenvalues? .
关于python - 使用 PCACompute2 计算特征值和特征向量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51788344/