Say I have 12 (x,y) positions:
data =
1.0000 0.8500
2.0000 1.1000
3.0000 1.2000
4.0000 0.9000
1.0000 2.0000
2.0000 2.1000
3.0000 1.9000
4.0000 2.0000
1.0000 3.1000
2.0000 3.1000
3.0000 2.9000
4.0000 2.8000
I want to classify these points into horizontal lines.
From a scatterplot it is easy for a human to see that the points form 3 horizontal lines;
one around y=1, another around y=2 and the last around y=3:

Which classification algorithm should I use to classify the points?
The easiest algorithm seem to be k-means. One problem with this is that I need to specify the number of clusters. How do one typically get around this problem? I was thinking that I may run it with an increasing number of clusters, n, and calculate the total square deviation from cluster mean and once the decrease in total square deviation relatively to the last number of clusters, n-1, is less than a certain threshold (say 1%) then n is a sufficient number of clusters.
Another algorithm I was considering using is hierarchical agglomerate clustering. The solution here would form a dendrogram, and like for the k-mean I may choose a level with n clusters for which the total deviation is below some threshold criteria.
One important piece of information that I do not understand how to use though in either of these algorithms is this; no cluster may have the same x position more than once! So far I have just ignored the x coordinate and clustered based on y values.
How can I use the criteria that no cluster may have the same x position more than once with a cluster algorithm?
Thanks in advance for any answers!


xvalue as the number of clusters? – Anony-Mousse Jul 6 '12 at 16:10