使用PCACompute2计算自身值和自身向量
Computing eigen values and eigen vectors using PCACompute2
我正在使用以下代码计算特征向量和特征值。
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? .
您需要安装 contrib
软件包
sudo -H pip install opencv-contrib-python
sudo -H pip install opencv-python