如何找到 Kmeans 总迭代次数?

How to find Kmeans total number of iterations?

我正在研究 k-means 算法。我使用统计工具的内置功能应用了 k-means 算法 box.I 并将其应用于大数据。我想知道函数将数据划分为最终集群所需的总迭代次数!我不是 MATLAB 的普通用户。请帮我找出迭代次数。

您需要使用 Name, Value 输入到 kmeans:

idx = kmeans(X,k,Name,Value)

具体来说,'Display','final''Display','iter' 如图所示 here

您可以查看 this example:

的输出示例
opts = statset('Display','final');
[idx,C] = kmeans(X,2,'Distance','cityblock',...
    'Replicates',5,'Options',opts);

Replicate 1, 4 iterations, total sum of distances = 201.533.
Replicate 2, 6 iterations, total sum of distances = 201.533.
Replicate 3, 4 iterations, total sum of distances = 201.533.
Replicate 4, 4 iterations, total sum of distances = 201.533.
Replicate 5, 3 iterations, total sum of distances = 201.533.
Best total sum of distances = 201.533