How to estimate K for K-means clustring
Show older comments
I'm working on unsupervised classification or clustering, i want to estimate the K (which refers to cluster number) before starting th k-means algorithm
Accepted Answer
More Answers (3)
the cyclist
on 15 May 2016
0 votes
This is not really a MATLAB question, but rather a general data science question.
Googling "how to choose k in k means" found this Wikipedia page on the topic (and many others) that might help you.
4 Comments
wisekily
on 15 May 2016
the cyclist
on 15 May 2016
Edited: the cyclist
on 15 May 2016
I don't know of any methods in MATLAB to help you choose K, other than plotting results post hoc to see how different choices of K did. See, for example, this page.
Image Analyst
on 15 May 2016
There are MATLAB functions for estimating the best k. I don't remember what they were - I'd have to look them up in the Machine Learning course notes.
wisekily
on 15 May 2016
Image Analyst
on 15 May 2016
0 votes
The web page on kmeans explains how you can use silhouette() to determine the best number of clusters, k:
3 Comments
wisekily
on 16 May 2016
Walter Roberson
on 16 May 2016
Did you read through the link that Image Analyst posted?
the cyclist
on 16 May 2016
Which is also the same link that I pointed you to earlier. So, uh, now you have 3 of the top 10 contributors to this forum telling you consistently the same thing.
kira
on 2 May 2019
old question, but I just found a way myself looking at matlab documentation:
klist=2:n;%the number of clusters you want to try
myfunc = @(X,K)(kmeans(X, K));
eva = evalclusters(net.IW{1},myfunc,'CalinskiHarabasz','klist',klist)
classes=kmeans(net.IW{1},eva.OptimalK);
1 Comment
Bashar Saad
on 12 Jul 2019
could you help me pleas the code is not clear
Categories
Find more on Cluster Analysis and Anomaly Detection in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!