What is the time complexity of k-means?

前端 未结 3 758
慢半拍i
慢半拍i 2021-02-04 07:06

I was going through the k-means Wikipedia page. Based on the algorithm, I think the complexity is O(n*k*i) (n = total elements, k = number

3条回答
  •  时光取名叫无心
    2021-02-04 07:39

    It depends on what you call k-means.

    The problem of finding the global optimum of the k-means objective function

    enter image description here

    is NP-hard, where Si is the cluster i (and there are k clusters), xj is the d-dimensional point in cluster Si and μi is the centroid (average of the points) of cluster Si.

    However, running a fixed number t of iterations of the standard algorithm takes only O(t*k*n*d), for n (d-dimensional) points, where kis the number of centroids (or clusters). This what practical implementations do (often with random restarts between the iterations).

    The standard algorithm only approximates a local optimum of the above function, and so do all the k-means algorithms that I've seen.

提交回复
热议问题