1

I am trying to perform MeanShift clustering on a list of numbers like this:

list = [4, 55, 8, 9, 12, 11, 11, 813, 832, 774, 781, 5, 769, 22]

X = np.reshape(list, (-1, 1))
ms = MeanShift(bandwidth = 30, bin_seeding = True)
ms.fit(X)
labels = ms.labels_
labels_unique = np.unique(labels)
n_clusters_ = len(labels_unique)

This returns:

number of estimated clusters : 4
[0 3 0 0 0 0 0 1 1 2 2 0 2 0]

However, I am not sure why 55 is labeled as cluster 3. How I wanted to label this was:

[0 1 0 0 0 0 0 3 3 2 2 0 2 0]

This would be labeling the clusters in ascending numerical order. Is there a way to do this in sklearn.cluster.MeanShift?

Eric
  • 57
  • 4

0 Answers0