我正在跟进Python 中的主成分分析 https://stackoverflow.com/questions/1730600/principal-component-analysis-in-python在Python下使用PCA,但我很难确定which可供选择的特征(即我的哪些列/特征具有最佳方差)。
当我使用scipy.linalg.svd
,它会自动对我的奇异值进行排序,所以我无法分辨它们属于哪一列。
示例代码:
import numpy as np
from scipy.linalg import svd
M = [
[1, 1, 1, 1, 1, 1],
[3, 3, 3, 3, 3, 3],
[2, 2, 2, 2, 2, 2],
[9, 9, 9, 9, 9, 9]
]
M = np.transpose(np.array(M))
U,s,Vt = svd(M, full_matrices=False)
print s
在不对奇异值进行排序的情况下,是否有其他方法可以解决此问题?
Update:看起来这可能是不可能的,至少根据 Matlab 论坛上的这篇文章:http://www.mathworks.com/matlabcentral/newsreader/view_thread/241607 http://www.mathworks.com/matlabcentral/newsreader/view_thread/241607。如果有人知道其他情况,请告诉我:)