admin管理员组文章数量:1122832
I’m working on a PCA loading plot and, based on the literature for my data, I expected IAF and B to fall within the smaller ellipse (less important variables). However, they are not; instead, RedEdge appears there.
I followed this guide: .html
What might I be doing wrong? My goal is to correctly place less important variables within the smaller ellipse. Any guidance would be appreciated!
variaveis_instrumentais = dados[['B', 'G', 'R', 'RedEdge', 'NIR', 'NDVI', 'NDRE',
'GNDVI', 'MPRI', 'SAVI', 'IAF', 'VARI']]
scaler = StandardScaler()
variaveis_instrumentais_normalizadas = scaler.fit_transform(variaveis_instrumentais)
pca = PCA(n_components=2)
pca.fit(variaveis_instrumentais_normalizadas)
loadings = pcaponents_.T * np.sqrt(pca.explained_variance_)
importantes = []
nao_importantes = []
for i, var in enumerate(variaveis_instrumentais.columns):
dist = np.sqrt(loadings[i, 0]**2 + loadings[i, 1]**2) # Distância da origem
if dist > 0.8:
importantes.append((var, loadings[i, 0], loadings[i, 1]))
else:
nao_importantes.append((var, loadings[i, 0], loadings[i, 1]))
for var, x, y in importantes:
plt.scatter(x, y, color='g')
plt.text(x, y, var, color='g', fontsize=12)
for var, x, y in nao_importantes:
plt.scatter(x, y, color='b')
plt.text(x, y, var, color='b', fontsize=12)
ellipse_outer = Ellipse((0, 0), width=2.0, height=1.5, edgecolor='black', fill=False, linestyle='--')
ellipse_inner = Ellipse((0, 0), width=1.4, height=1.0, edgecolor='black', fill=False, linestyle='-')
plt.gca().add_artist(ellipse_outer)
plt.gca().add_artist(ellipse_inner)
The result was:
The expected result:
本文标签: pythonIssues in Visualizing Variable Importance in PCA Loading PlotsStack Overflow
版权声明:本文标题:python - Issues in Visualizing Variable Importance in PCA Loading Plots - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736300693a1930908.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论