what is the best way(plot or....) to show my error according to benchmark in clustering?

2 views (last 30 days)
I have my own clustering and i'm going to compare it precision according to benchmark .benchmark clustered in 7 clusters and each point has the number (1:7)which shows which cluster it belongs to. in my code I clustered data in 7 clusters and assign them a number(1:7)but surely the clusters numbers are not the same as benchmark.
so Im looking for the best way(plot or....) to show my error according to benchmark in clustering.
thanks for any help.

Accepted Answer

Image Analyst
Image Analyst on 23 Nov 2018
Use a "confusion matrix". There are several function for that in the Statistics and Machine Learning Toolbox, and the Deep Learning Toolbox.
  2 Comments
alireza kooshafar
alireza kooshafar on 23 Nov 2018
thanks a lot .
i found ''plotconfusion'' and it is exactly what i wanted, but the problem is diffrent between numbers assigned to clusters in my code and in benchmark data(for example the data in cluster number 2 of benchmark are in cluster number 5 in result of my code ),is there any way to solve this?
Image Analyst
Image Analyst on 23 Nov 2018
Yes. To get the cluster numbers for kmeans() to match up with the cluster number for your reference, then you have to get the centroids for all clusters in both data sets. Then you can use sqrt() or pdist2() to figure out what reference cluster is closest to what test cluster (which cluster has the min distance). Then you can keep a list of what cluster is the desired cluster and use intlut() to relabel the classes. Let's say that cluster 1-4 in the ref set were actually closest to sets [1,4,2,3]. In other words, cluster 1 is closest to red cluster 1, test cluster 4 is actually closest to cluster 2 of the ref set, and test cluster 2 was actually closest to ref cluster 3, and test cluster 3 was closest to ref cluster 4. So then you'd relabel the the indexes
[testClassNumbers, testClassCentroids] = kmeans(.....
% Make correspondence vector
newTestClassNumbers = intlut(v);
% Then reorder the Centroids in the same order, if you need to

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!