如何用距离矩阵与k个medoids进行聚类

时间:2019-07-18 05:53:53

标签: python-3.x

我有如下距离矩阵:

array([[0, 0.66666667, 1.63636364, 1.33333333, 1.5],
   [0.66666667, 0.        , 1.33333333, 0.85714286, 1.11111111],
   [1.63636364, 1.33333333, 0.        , 0.66666667, 0.35294118],
   [1.33333333, 0.85714286, 0.66666667, 0.        , 0.33333333],
   [1.5       , 1.11111111, 0.35294118, 0.33333333, 0.        ]])

我使用以下代码进行集群:

from sklearn.metrics.pairwise import pairwise_distances
import numpy as np
import pyclustering
from pyclustering.cluster.kmedoids import kmedoids

# create K-Medoids algorithm for processing distance matrix
kmedoids_instance = kmedoids(matrix, initial_medoids, 
data_type='distance_matrix')
# run cluster analysis and obtain results
kmedoids_instance.process()
clusters = kmedoids_instance.get_clusters()
medoids = kmedoids_instance.get_medoids()

但是如何选择initial_medoids? 以及如何找到最佳数目的簇?

请帮助

0 个答案:

没有答案