# k-mean without label [closed]

i m try to apply k-means with Python 3 to my dataset (Amazon review) for classify similar user (from review).

I just have a TF and TF-IDF matrix (and i have a row(user) and columns(words) value in distinct csv file)

I m starting with sklearn from this sketch

https://scikit-learn.org/stable/auto_examples/text/plot_document_clustering.html#sphx-glr-auto-examples-text-plot-document-clustering-py

but in my case i don't have label or category, and i don't understand how k-means can cluster different items from this matrix TD-IDF.

1. How can I group similar words from my dataset, from the matrix without having any information?
2. How do I show these n-clusters in the chart?
3. And how do I show the similar words of this cluster, if I do not have any information (like label or category)?

For now this is my code :

k = 5
km = KMeans(n_clusters=k, init='k-means++', max_iter=100, n_init=5)
km.fit(Y) ##Y is my TD-IDF matrix

original_centroids = svd.inverse_transform(km.cluster_centers_)
print(original_centroids.shape)
for i in range(original_centroids.shape[0]):
original_centroids[i] = np.array([x for x in original_centroids[i]])
svd_centroids = original_centroids.argsort()[:, ::-1]


i would like have a set like this(with similar word near)

I m very lost, because i m new in this word.

• There is no question... – Mark.F Dec 30 '18 at 9:17
• the question is...how to apply k-means without the label. I edit the question – theantomc Dec 30 '18 at 9:19
• The question doesn't make sense; k-means is an unsupervised technique and by nature has nothing to do with labels – Sean Owen Dec 30 '18 at 14:32
• maybe I have to reformulate the question. Unfortunately I saw only this example and I saw these labels and maybe I was too tied to this particular. @SeanOwen My question was more specific than k-means, because I was trying to catalog users in different groups, but I understand how it is possible (it seems too magical) how I can divide them without knowing anything except the TD-IDF matrix and print with that example of related topics. This is why I tied myself to those labels.. I will edit the question. – theantomc Dec 30 '18 at 23:43
• @theantomc are you trying to cluster words or users. In the edit you proposed it says you are trying to cluster words, for which k-means would be the wrong method but if it's user what you are trying to cluster then this question could be edited to reflect that intention. – wacax Dec 31 '18 at 13:54