Code covered by the BSD License  

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Fast K-means clustering

4.0 | 2 ratings Rate this file 36 Downloads (last 30 days) File Size: 1.46 MB File ID: #33541 Version: 1.6
image thumbnail

Fast K-means clustering



31 Oct 2011 (Updated )

Fast mex K-means clustering algorithm with possibility of K-mean++ initialization.

| Watch this File

File Information

Fast mex K-means clustering algorithm with possibility of K-mean++ initialization
(mex-interface modified from the original yael package

- Accept single/double precision input
- Support of BLAS/OpenMP for multi-core computation

Please run mexme_yael_kmeans.m to compile mex-files (be sure that mex -setup have been done at least one)

Run demo "test_yael_kmeans.m"


This file inspired Ziheng Gmm.Zip and Sparsified K Means.

Required Products MATLAB
MATLAB release MATLAB 7.9 (R2009b)
Other requirements For a full usage, a OpenMP C compiler compliant such MSCV/Intel compiler/GCC. Shoud work with LCC but without OpenMP support.
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (14)
31 Oct 2014 Kathrin

Dear Sebastien,
I had compiled the mex-files successfully.The "sample_mvgm" and " ndellipse" were executed successfully while there were something wrong with "yael_kmeans".It was reported that "matlab has matlab has encountered an internal problem and needs to close ".
Please give me a hand.
Compiler: Microsoft Software Development Kit (SDK) 7.1
MatlabRelease: matlab (R2012a)

07 Jun 2013 Kota Hara  
07 Jun 2013 Kota Hara

Thank you for checking. The reason is that there are cases where the cardinality of the data is unknown before applying clustering. Well, I can first check the cardinality of the data and then use k <= cardinality but I just thought it would be great if your code could handle that situation.

Comment only
06 Jun 2013 Sebastien PARIS


I confirmed the bahaviour. In another way, why ask more clusters than the cardinality of your data ?

Comment only
31 May 2013 Sebastien PARIS


Thank you for reporting.... I will check this

Comment only
30 May 2013 Kota Hara

My input data X is a set of one dimensional scalar and the values are taken from a finite discrete set S, e.g., S = {1,2,3,4,5}. When I run yael_kmeans with K>|S|, it looks like yael_kmeans goes into an infinite loop. Do you have any idea on how to fix it?

Comment only
26 Dec 2012 Sebastien PARIS

Can you indicate what is your OS, CPU and compiler used ? Did you recompile mex-files also ?

Comment only
26 Dec 2012 Sepehr Farhand

Matlab crashes w/ segmentation fault. I guess you have a loose pointer somewhere. "Segmentation violation detected"

Comment only
02 Oct 2012 Sebastien PARIS

Leila ...

It supports of course 3d vectors or more ...

Comment only
03 Jul 2012 leila

leila (view profile)

Does the code support 3d data?

Comment only
29 Jun 2012 Sebastien PARIS

Thank you for reporting ...
The update with correction will be published soon.

Comment only
28 Jun 2012 Bonolo

Bonolo (view profile)

on the mac, need to change lib= '-lmwblas'; to libblas= '-lmwblas';

otherwise compiles fine.

Comment only
30 May 2012 Sebastien PARIS


Did you compile mex-files first ?

Please run mexme_yael_kmeans.m to compile mex-files (be sure that mex -setup have been done at least one)

Comment only
30 May 2012 Vladimir

Using MSVC++ 2010 compiler, sample_mvgm throws an error when called in test_yael_kmeans:
"mu must be (d x 1 x M x n1 x ... x nl)"
mu = cat(3 , [-2.5 ; -3] , [0 ; 0] ,[ 5 ; 5]); %(d x 1 x M)

Comment only
01 Nov 2011 1.1

- Add online help, minor changes

04 Nov 2011 1.2

- Minor changes
- Add spiral clustering example in the test file

24 Mar 2012 1.3

-Correct a bug in randperm

29 Jun 2012 1.4

-Correct a bug in mexme_yael_kmeans.m for Linux/Mac Os

27 Sep 2012 1.5

- Fix a bug in ndellipse introduced in the last update

09 Nov 2012 1.6

- Fix compilation issue in mexme_yael_kmeans
- Include both mexw32 & mexw64 files in two separate files (unzip them in local dir in case of problem)

Contact us