How can I do clustering with one variable input

433 Views Asked by At

I have a one dimensional data with 10,000 rows.

I like to do some group/clustering of these values.

I was trying to do k-menas clustering but it looks with one variable it's not quite possible.

I have tried to do clustering as follows but it looks getting only o cluster:

import matplotlib.pyplot as plt
from matplotlib import style
style.use("ggplot")

from sklearn.cluster import KMeans

kmeans = KMeans(n_clusters=5)
kmeans.fit(X)

centroid = kmeans.cluster_centers_
labels = kmeans.labels_

print (centroid)
print(labels)
[[  4450.09824891]
 [330963.43209877]
 [ 52145.48325359]
 [634299.        ]
 [146308.2320442 ]]
[0 0 0 ... 0 0 0]

Would anybody Please help me to get the clustering with one variable?

Thanks in advance.

0

There are 0 best solutions below