gpt4 book ai didi

python - 使用 PCACompute2 计算特征值和特征向量

转载 作者:太空宇宙 更新时间:2023-11-03 22:42:17 24 4
gpt4 key购买 nike

我使用以下代码计算特征向量和特征值。

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com