Sklearn Kmeans参数混乱吗? [英] Sklearn Kmeans parameter confusion?

查看:66
本文介绍了Sklearn Kmeans参数混乱吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我可以按以下方式运行sklearn kmeans:

So I can run sklearn kmeans as the following:

kmeans = KMeans(n_clusters=3,init='random',n_init=10,max_iter=500)

但是我对参数的含义有些困惑

But I'm a little confused on what the parameters mean

所以 n_init 说:

使用不同质心种子运行k均值算法的时间.就惯性而言,最终结果将是n_init个连续运行的最佳输出.

Number of time the k-means algorithm will be run with different centroid seeds. The final results will be the best output of n_init consecutive runs in terms of inertia.

max_iter 说:

单次运行的k-means算法的最大迭代次数.

Maximum number of iterations of the k-means algorithm for a single run.

但是我不完全理解那是什么意思.给定初始质心集,n_init是质心接近点的次数吗?

But I don't completely understand what that means. Is n_init the number of times the centroids are moved closer to the points mean, given an initial set of centroids?

max_iter是整个算法以新的初始质心运行的次数吗?

And is max_iter the number of times the whole algorithm is run with new initial centroids?

因此,例如,对于max_iter=2n_init=15,kmeans将选择初始质心,然后将这些质心移动15次并得出聚类结果.然后kmeans将再次选择初始质心,将这些质心移动15次,然后停止.然后,它将从两次运行中挑选出最佳的选择吗?

So for example, with max_iter=2,n_init=15, kmeans will choose initial centroids, then move those centroids 15 times and come up with a clustering result. Then kmeans will choose initial centroids again, move those centroids 15 times, and stop. Then, it will pick the best clutering out of the two runs?

感谢您的帮助!

还是与我在这里的完全相反...?

Or is the the exact opposite of what I have here... ?

推荐答案

在使用max_iter=2n_init=15时,kmeans将选择初始质心15次,并在15次运行中每次向上移动两次.

With max_iter=2 and n_init=15, kmeans will choose initial centroids 15 times and move up to twice on each of the 15 runs.

默认值为n_init=10max_iter=300.这意味着初始质心将被选择10次,并且每次运行最多将使用300次迭代.这10次测试中最好的是最终结果.

The default values are n_init=10 and max_iter=300. This means the initial centroids will be chosen 10 times, and each run will use up to 300 iterations. The best out of those 10 runs will be the final result.

这篇关于Sklearn Kmeans参数混乱吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆