Aug-17-2018, 06:17 PM
I have performed kmeans clustering on a dataset with term frequencies. I have created 5 clusters. Now I want to combine the true labels of the frequencies to the actual terms in another document called "terms".
Basically I want to combine the frequencies to terms and then make 5 wordclouds for the 5 clusters.
I have some code written, but not able to do that successfully.
The code I have is:
Not sure what the problem is. Any help would be appreciated. Thanks
Basically I want to combine the frequencies to terms and then make 5 wordclouds for the 5 clusters.
I have some code written, but not able to do that successfully.
The code I have is:
arr = [] j = 0 v = np.where(np.asarray(assigned_clusters) == 0) words = terms #list(model.vocab) for i, word in enumerate(words): print(word + ":" + str(v[i])) arr.append(word) abc = str(arr) wordcloud = WordCloud(stopwords=STOPWORDS,background_color='white', width=1200, height=1000).generate_from_text(abc) print(wordcloud.words_) fig = plt.figure() plt.imshow(wordcloud) plt.show()I am getting syntax errors from arr.append() and onwards
Not sure what the problem is. Any help would be appreciated. Thanks