How do I find which cluster my data belongs to using Python?

后端 未结 2 1971
谎友^
谎友^ 2021-01-27 05:21

I just ran PCA and then K-means Clustering algorithm on my data, after running the algorithm I get 3 clusters. I am trying to figure out which clusters my input belongs to , in

2条回答
  •  無奈伤痛
    2021-01-27 06:04

    If you want to add the cluster labels back in your dataframe, and assuming x_10d is your dataframe, you can do:

    x_10d["cluster"] = X_clustered

    This will add a new column in your dataframe called "cluster" which should contain the cluster label for each of your rows.

提交回复
热议问题