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:
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.
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))