我正在研究聚类问题。为了确保结果的重现性,我们最初将
random_state
中的 KMeans()
参数设置为 0。但是,在将 scikit-learn 从版本 0.22.2 更新到版本 1.2.2 后,我遇到了意外的问题。当我使用相同的数据集运行相同的代码时,结果与之前的运行不同。我们不确定这种不一致背后的原因,并且无法重现最初的结果。
代码:
model = KMeans(n_clusters=5, init='k-means++', tol=0.0001, random_state=0, copy_x=True, algorithm='auto' )
预期结果 簇数 = 5
Cluster 1 | Cluster 2 | Cluster 3 | Cluster 4| cluster 5
10| 20| 12| 30|45
实际结果
版本0.22.2: 簇数 = 5
Cluster 1 | Cluster 2 | Cluster 3 | Cluster 4| cluster 5
10| 5| 6| 14|5
版本1.2.2: 簇数 = 5
Cluster 1 | Cluster 2 | Cluster 3 | Cluster 4| cluster 5
3| 7| 20| 8|2