[英]How can I find the data point in my PCA plot in python?
我在 python 中制作了這個 PCA 圖,我想知道每個點的名稱或索引如何找到方法?
def pca_arrows_2d(df, pca) :
feature_vectors = pca.components_.T
# échelle des flèches
arrow_size, text_pos = 7.0, 8.0,
# projections des vecteurs de caractéristiques
for i, v in enumerate(feature_vectors):
plt.arrow(0, 0, arrow_size*v[0], arrow_size*v[1],
head_width=0.2, head_length=0.2, linewidth=2, color='red', alpha = 0.5)
plt.text(v[0]*text_pos, v[1]*text_pos, df.columns[i], color='grey',
ha='center', va='center', fontsize=18)
sns.pairplot(x_vars=[0], y_vars=[1], data=df_pca, hue="classes", height=10)
pca_arrows_2d(X, pca)
使用可視化包 plotly 創建繪圖。 您可以在繪圖周圍移動光標並查看數據和點。 Plotly 可幫助您查找數據並識別可視化中的數據點,並且使用起來非常簡單。
你也可以參考這個:
我希望這會有所幫助,這就是您想要的?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.