看 kmeans
里面文档有写:
The Hartigan-Wong algorithm generally does a better job than either of those, but trying several random starts (‘nstart’> 1) is often recommended.
In rare cases, when some of the points (rows of ‘x’) are extremely close, the algorithm may not converge in the “Quick-Transfer” stage, signalling a warning (and returning ‘ifault = 4’).
两个建议:
1. 尝试一下Lloyd 或者 MacQueen 算法。
2. 提高迭代次数