首页 > 解决方案 > 使用 PCA 或 t-SNE 和 Matplotlib 测量数据图

问题描述

我的目标是找出我是否可以在 Python 中操作和测量来自 PCA 或 t-SNE 图的数据。我想知道是否有一种方法可以找到点到集群中心的距离。

我认为有办法,但我不太确定。

标签: pythonmatplotlibkeraspcadimensionality-reduction

解决方案


您没有指定太多,但也许这可以帮助您:

聚类技术信息: https ://scikit-learn.org/stable/modules/clustering.html#clustering

降维: https ://scikit-learn.org/stable/modules/decomposition.html#decompositions

也许以下脚本可以帮助您:

from sklearn.decomposition import PCA

    X= your_data_variables
    cluster = "your cluster technique"   
    cluster.fit(X)
    pca=PCA(n_components= 2)
    pca.fit(X)
    pca_data = pd.DataFrame(pca.transform(X))
    centers = pca.transform(cluster.cluster_centers_)

现在您有了集群中心和二维数据,您可以根据需要计算距离。


推荐阅读