[英]How can I find the data point in my PCA plot in python?
I made this PCA plot in python and I want to know the name or index of each point how can I find a way?我在 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)
Use visualization package plotly to create plots.使用可视化包 plotly 创建绘图。 You can move cursors around the plot and see the data and points.
您可以在绘图周围移动光标并查看数据和点。 Plotly helps you to find the data and identify the data points in the visualization and its very simple to use.
Plotly 可帮助您查找数据并识别可视化中的数据点,并且使用起来非常简单。
You can also refer this:你也可以参考这个:
How can I find the data point in my PCA plot in r? 如何在 r 的 PCA 图中找到数据点?
I hope this helps and this is what you wanted?我希望这会有所帮助,这就是您想要的?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.