# KMeans Clustering on Heterogeneous Dataset

I have a sample dataset as below:

Data_1,Data_2,Data_3,Data_4,Data_5,Data_6,Data_7,Data_8 93.966589,6.033411,93.966589,6.033411,93.966589,6.033411,1296.257118,1044.073206 93.966589,6.033411,93.966589,6.033411,93.966589,6.033411,1296.257118,1044.073206 93.966589,6.033411,93.966589,6.033411,93.966589,6.033411,1296.257118,1044.073206 93.966589,6.033411,93.966589,6.033411,93.966589,6.033411,1296.257118,1044.073206 93.966589,6.033411,93.966589,6.033411,93.966589,6.033411,1296.257118,1044.073206 96.853313,3.146687,96.853313,3.146687,96.853313,3.146687,1233.525837,1076.147926 96.853313,3.146687,96.853313,3.146687,96.853313,3.146687,1233.525837,1076.147926 96.853313,3.146687,96.853313,3.146687,96.853313,3.146687,1233.525837,1076.147926 96.853313,3.146687,96.853313,3.146687,96.853313,3.146687,1233.525837,1076.147926 96.853313,3.146687,96.853313,3.146687,96.853313,3.146687,1233.525837,1076.147926

It has two data points repeated in a uniform way. As per the clustering logic, the ideal number of clusters for this dataset should be two. Is this correct or should the identical values be considered duplicate?

Does clustering work better for heterogeneous data or it should work for these kind of data too?

Thanks.

K-means attempts to group distributions into $k$ similar categories based on some metric of nearness. If your dataset contains repeated values this is not a problem. It simply means that you have 2 distributions from which you are drawing instances, and the variance of these distributions is essentially zero.

For example, if you have a dataset from which you want to cluster two species of fish with 2 features: color and length. However, the fish of each species are all clones (ignore other biology stuff i know nothing about like environmental factors). Thus they will all have exactly the same color and the same length in either group. Each measurement of each individual will be exactly the same. This is fine. We simply have 0 variance in each distribution.

Clustering is very well suited for very tight distributions because they are easily separable. However, distributions with high variance will have significant overlap and will thus cause many instances to be wrongfully classified as being a part of the other cluster.

# The ideal number of clusters

This value can be calculated by determining the average distance between each instance and its nearest cluster. You will see that once you surpass 2, the average distance will not decrease in any further in this case, which means a single distribution is being split into 2 groups. Thus 2 is the ideal number of clusters.

Technically, it is allowed to duplicate observations (records) to cluster, yet it is far from correct. What I'd do is first apply grouping similar records and use unique observations with a weight being their frequency. Weight of observation can be used in many clustering algorithms.

It will be faster to merge duplicates.

But you can run k-means with duplicates, obviously.

Don't forget preprocessing & result validation!