Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between kmeans and kmeans2 in scipy?

I am new to machine learning and wondering the difference between kmeans and kmeans2 in scipy. According to the doc both of them are using the 'k-means' algorithm, but how to choose them?

like image 781
Mickey Shine Avatar asked Dec 18 '13 14:12

Mickey Shine


1 Answers

Based on the documentation, it seems kmeans2 is the standard k-means algorithm and runs until converging to a local optimum - and allows you to change the seed initialization.

The kmeans function will terminate early based on a lack of change, so it may not even reach a local optimum. Further, the goal of it is to generate a codebook to map feature vectors to. The codebook itself is not necessarily generated from the stoping point, but will use the iteration that had the lowest "distortion" to generate the codebook. This method will also run kmeans multiple times. The documentation goes into more specifics.

If you just want to run k-means as an algorithm, pick kmeans2. If you just want a codebook, pick kmeans.

like image 132
Raff.Edward Avatar answered Nov 01 '22 21:11

Raff.Edward