MiniBatchKmeans 结果的实施问题

problem with implementation of MiniBatchKmeans result

在知道我使用 MiniBatchKmeans 后多次执行我的算法后是否可能有不同的簇大小? 也就是说:

cluster 1: size = 30 cluster 2: size = 24 cluster 3: size = 2

在重新执行小批量之后, cluster 1: size = 15 cluster 2: size = 20 cluster 3: size = 21

kmeans = MiniBatchKMeans(n_clusters=nbK, init ='k-means++', max_iter=1000, max_no_improvement = 10)
kmeans.fit(X)

prediction = kmeans.predict(X)

您应该修复 random_state 以获得确定性结果。

kmeans = MiniBatchKMeans(n_clusters=nbK, init ='k-means++', max_iter=1000, max_no_improvement = 10, random_state=10)

查看文档:https://scikit-learn.org/stable/modules/generated/sklearn.cluster.MiniBatchKMeans.html