【发布时间】:2021-04-21 14:01:39
【问题描述】:
我正在尝试对文本单词进行聚类。 假设我有一个文本列表
text=["WhatsApp extends 'confusing' update deadline",
"India begins world's biggest Covid vaccine drive",
"Nepali climbers make history with K2 winter summit"]
我在这个数据上实现了 TF-IDF
vec = TfidfVectorizer()
feat = vec .fit_transform(text)
之后,我应用了 Kmeans
kmeans = KMeans(n_clusters=num).fit(feat)
我很困惑的是我如何获得诸如
之类的词组cluster 0
WhatsApp, update,biggest
cluster 1
history,biggest ,world's
etc.
【问题讨论】:
-
我猜你的字符串列表坏了。有一些 ' 和 , 缺失。你的代码的结果是什么?
标签: python scikit-learn k-means tf-idf