hupili / python-for-data-and-media-communication-gitbook

An open source book on Python tailed for communication students with zero background
115 stars 62 forks source link

clustering - Kmeans, Agglomerative, and DBSCAN #147

Open ivywze opened 5 years ago

ivywze commented 5 years ago

Troubleshooting

Describe basic

Describe your question

For a data set with 100 records, for all K value in 1<= K <= 100, the K-means clustering algorithm returns only one non-empty cluster. Incremental version of K-means returns exact same result. How is this possible?

And would single link and DBSCAN handle such data?

Describe the efforts you have spent on this issue

For each data points with same distance to all other points clearly doesn’t work here. Besides all data points with no distance (100 of them at exact one position), is there any other possibilities?

Have you Google/ Stackover flow anything?

Nothing found.

hupili commented 5 years ago

Sounds like a case where:

Without looking at the exact data, you can try the following methods:

  1. Normalise all the records, in case the distance is too small in original space.
  2. Manually set K-means centroid initial values. If you intend to have K clusters, randomly pick K data points to be the initial centroids.

Which algorithm is better is hard to tell without looking at the data. We can focus on making K-means work first.

ivywze commented 5 years ago

In sklearn.cluster.KMeans if set ( init=’random’), seems the centroid will be randomly picked. And if random to choose centroids and run for many times but obey the same result, I guess it rules out the possibility that the distance between data points is smaller than the distance between centroid, because it's already random.

Looks like there left only one situtation that there is no distance at all of are the data points.

ivywze commented 5 years ago

If the dataset has infinite many data points, seems under some distance constrictions the data shape like Paraboloid may result in just only one non-empty cluster. But for the dataset with limited data points, it's unlikely to have the result.