Kmeans:两个版本 0.22.2 和 1.2.2 之间具有相同 random_state 的不同聚类结果

问题描述 投票:0回答:0

我目前正在研究聚类问题。为了确保结果的重现性,我们最初将 KMeans() 中的 random_state 参数设置为 0。但是,在将 scikit-learn 从版本 0.22.2 更新到版本 1.2.2 后,我遇到了意外的问题。当我使用相同的数据集运行相同的代码时,结果与之前的运行不同。我们不确定这种不一致背后的原因,并且无法重现最初的结果。

重现步骤/代码 模型 = KMeans(n_clusters=5, init='k-means++', tol=0.0001, random_state=0, copy_x=True, Algorithm='auto' )

预期结果

版本0.22.2: 簇数 = 5

    Cluster 1 | Cluster 2 | Cluster 3 | Cluster 4| cluster 5
            10| 20| 12| 30|45

版本1.2.2: 簇数 = 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
scikit-learn cluster-analysis k-means python-3.9 python-3.10
© www.soinside.com 2019 - 2024. All rights reserved.