Printing k-means clustered clusters - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: Printing k-means clustered clusters (/thread-25592.html) |
Printing k-means clustered clusters - ottabe_h - Apr-04-2020 I'm trying to print the number of the cluster and the words inside the cluster. Out put should be: Cluster 1: dog run walk Cluster 2: three four Here's the making of he clusters: def kmeans_clustering(words): n_clusters = 3 clusterer = KMeansClusterer(n_clusters, euclidean_distance, repeats=10) vectors = [numpy.array(normalize(context_vector[word])) for word in words] assigned_clusters = clusterer.cluster(vectors, assign_clusters=True, trace=True) kmeans_clustering('three four dog run walk'.split())I tried to iterate through the word and then append the the cluster number and the word to a list, but I get a out of range error and I intuitively also think it might not work. This is the only thing I have gotten to work, but it's not what I want. for i, word in enumerate(words): print ('Cluster', str(assign_clusters[i], word)) RE: Printing k-means clustered clusters - pyzyx3qwerty - Apr-05-2020 Please use proper code tags while posting a thread RE: Printing k-means clustered clusters - deanhystad - Apr-07-2020 Does your problem have anything to do with K Means Clustering, or is it just processing your results? Please provide more detail and show what you have tried and the error message you are getting. RE: Printing k-means clustered clusters - piotrkuras - May-19-2021 Good Morning, I am a student at the University of Rzeszow. As part of my master's thesis, I am conducting a study on the use of data clustering methods. Please complete the survey found at the link https://forms.gle/tK8mdjbxaKeRAQpm7. The survey is anonymous and consists of 9 short questions. Thank you for your time. Piotr Kuras |