File Exchange

image thumbnail

kmeans_opt

version 1.0.0.1 (1.86 KB) by Sebastien De Landtsheer
tries k-means over different number of clusters

35 Downloads

Updated 04 Apr 2019

View License

k-means is a decent clustering algorithm, however it requires the specification of the number of clusters, and is stochastic.
This function takes a matrix as input, as well as the maximum number of clusters, the cutoff to determine the best model (the fraction of variance explained), and makes sure the results are stable by repeating a number of times specified by the user.
The above method is called the Elbow method.

Cite As

Sebastien De Landtsheer (2019). kmeans_opt (https://www.mathworks.com/matlabcentral/fileexchange/65823-kmeans_opt), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (7)

My version of Matlab won't execute (X-MIN) where X is a something-by-c matrix and MIN is a 1-by-c vector. Is this allowed in later versions of MATLAB?

Bo Xia

I tried using this algorithm to determine the optimal cluster number for my data of 15 points (x and y coordinates) which I used as the input but I am getting the following error message "Error in kmeans_opt (line 33)
[m,~]=size(X); %getting the number of samples". Please help.

KAE

Did well on my dataset and was faster than Matlab's evalclusters.m, for the data I was looking at.

Updates

1.0.0.1

New version as of 4th April 2019: unit-normalizes the variables, so the algo works even if the variables are on completely different styles.

MATLAB Release Compatibility
Created with R2017a
Compatible with any release
Platform Compatibility
Windows macOS Linux