3.88889

3.9 | 9 ratings Rate this file 54 Downloads (last 30 days) File Size: 2.02 KB File ID: #19344
image thumbnail

Efficient K-Means Clustering using JIT

by

 

27 Mar 2008 (Updated )

A simple but fast tool for K-means clustering

| Watch this File

File Information
Description

This is a tool for K-means clustering. After trying several different ways to program, I got the conclusion that using simple loops to perform distance calculation and comparison is most efficient and accurate because of the JIT acceleration in MATLAB.

The code is very simple and well documented, hence is suitable for beginners to learn k-means clustering algorithm.

Numerical comparisons show that this tool could be several times faster than kmeans in Statistics Toolbox.

Acknowledgements

This file inspired Patch Color Selector.

MATLAB release MATLAB 7.5 (R2007b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (11)
12 Jul 2012 Nikolay S.  
03 Jul 2012 leila

Does the code support 3d data?

29 Feb 2012 S.Karthi  
13 May 2011 Maxime

Although not a perfect way to solve the above-mentioned issue, adding the following two lines after the update of the centroids solved the problem in my case:

idnan = find(isnan(c(:,1)));
c(idnan,:) = X(randi(n,length(idnan),1),:);

13 May 2011 Maxime

Pretty fast indeed!

However, the number of cluster is sometimes not respected. The algorithm yields a lower number of clusters, replacing additional centroid by NaN. This can be inconvenient.

06 Apr 2011 Tim Benham

The function fails to terminate on some inputs. For example see http://snipt.org/wpkI

17 Aug 2010 Nandha  
08 Jul 2009 Edgar Kraft

The code is very nice and well documented. In some cases, however, the clusters are not properly identified if no initial centroid vectors are provided. This could be improved by automatically trying a small number of different random initial guesses and chosing the configuration which yields the smallest sum of distance between points and centroids.

05 Apr 2009 V. Poor  
16 Mar 2009 Mo Chen  
18 May 2008 nicola rebagliati

this stuff works and examples/comparisons are given

Updates
27 Mar 2008

update description

Contact us