sklearn PCA,2个组件中的一个功能。错误在哪里?

问题描述 投票:0回答:1

我正在执行PCA并根据解释的最大值_ratio_提取特征

错误:在两个组件中,最大组件具有相同的索引,即对应于相同的特征。换句话说-相同功能被视为两倍于最大组件。

任何人都知道可能是什么问题吗?

'''

print(np.abs(model.components_[83]).argmax())
215
print(np.abs(model.components_[87]).argmax())
215

print(model.components_[83][215])
-0.08783137996764155
print(model.components_[87][215])
-0.09858398917798368

nr of features to analyze:  1393

print(len(model.components_[83]))
1393

nr of features chosen by PCA:  125

'''

python scikit-learn pca
1个回答
0
投票
idx = model.explained_variance_.argmax()

然后与之相关的特征向量将是:

model.components_(idx, :)

此向量的长度应为输入空间中要素的数量

© www.soinside.com 2019 - 2024. All rights reserved.