Sklearn : Mean Distance from Centroid of each cluster

前端 未结 4 1324
难免孤独
难免孤独 2021-01-04 22:52

How can i find the mean distance from the centroid to all the data points in each cluster. I am able to find the euclidean distance of each point (in my dataset) from the ce

4条回答
  •  南方客
    南方客 (楼主)
    2021-01-04 23:49

    You can use following Attribute of KMeans:

    cluster_centers_ : array, [n_clusters, n_features]

    For every point, test to what cluster it belongs using predict(X) and after that calculate distance to cluster predict returns(it returns index).

提交回复
热议问题