1
$\begingroup$

I have a data sets which has two columns. I am trying to apply k mean clustering but result does not satisfy me. What i see with my naked eye is better than the clustering result so is there anyway to improve my clustering. Here is the data without clustering. I can basically see three clusters

a

When i apply k mean clustering with the following code i get the below result which does not make a sense. I think red and green should be in the same cluster and the blue should be separated from ~200 (on the x-axis).

opts = statset('Display','final'); [idx,C] = kmeans(wpf,3,'Distance','sqeuclidean',... 'Replicates',10,'Options',opts); k_mean=figure; plot(wpf(idx==1,1),wpf(idx==1,2),'r.','MarkerSize',12) hold on plot(wpf(idx==2,1),wpf(idx==2,2),'b.','MarkerSize',12) plot(wpf(idx==3,1),wpf(idx==3,2),'g.','MarkerSize',12) legend('Cluster 1','Cluster 2','Cluster 3',... 'Location','NW') b

I need you guys help. If you are interested, i can also provide raw data sets.

$\endgroup$
  • $\begingroup$ Have you tried performing multiple kmeans runs? It's very sensitive to the starting centroids, which are randomly initiated. $\endgroup$ – ilanman Nov 2 '16 at 15:15
  • $\begingroup$ I think this part " 'Replicates',10" in my above code performing multiple k-means runs $\endgroup$ – Cagatay Yilmaz Nov 7 '16 at 6:36
2
$\begingroup$

First of all, k-means is sensitive to scaling. Your x axis has a much larger scale than your y axis. Try looking at an undistorted image to understand what is happening. Imagine stretching your image 7x on the x-axis, would you still recognize the same clusters?

Beware that results will non-comparable attributes are usually not very reliable. So even if you scale your data, the results may be unpredictable (when your data changes) or statistically questionable.

Consider using Gaussian Mixture Modeling rather than k-means, or DBSCAN, because these are density-based clusters.

After standardizing your data, and using DBSCAN with eps=0.14 and minpts=50, I get for example this result (I chose eps based on the OPTICS plot):

DBSCAN

But as expected, EM works better here. In particular once you choose four clusters, because apparently the right one are two overlapping clusters; one with little covariance, and one with negative covariance.

It's worth also looking at the histograms, or a kernel density plot. Because the cluster on the left is very thin compared to the others, i.e. the data is rather unbalanced. I used ELKI for these experiments.

EM clustering

$\endgroup$
  • $\begingroup$ i could not figure out how to apply dbscan because of its user defined inputs such as eps and minpts. Can you show me how to do that if possible? Again if you want i can provide raw data. $\endgroup$ – Cagatay Yilmaz Nov 7 '16 at 11:32
  • $\begingroup$ Imcertainly can't without data... $\endgroup$ – Anony-Mousse Nov 7 '16 at 20:40
  • $\begingroup$ how can i send the data? the data is txt file. $\endgroup$ – Cagatay Yilmaz Nov 8 '16 at 13:09
  • $\begingroup$ Either way, load it into ELKI, try EM with k=3. $\endgroup$ – Anony-Mousse Nov 8 '16 at 20:25
  • $\begingroup$ Here is the link for my data myweb.sabanciuniv.edu/cagatayyilmaz/files/2013/08/myFile.txt $\endgroup$ – Cagatay Yilmaz Nov 9 '16 at 9:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.