2021年1月16日星期六

Get clusters of words using Kmeans and TF-IDF

I am trying to clusters text words. Let suppose I have a list of text

text=["WhatsApp extends 'confusing' update deadline",  "India begins world's biggest Covid vaccine drive",  "Nepali climbers make history with K2 winter summit"]  

I implemented TF-IDF on this data

vec = TfidfVectorizer()  feat = vec .fit_transform(text)  

After that, I applied Kmeans

kmeans = KMeans(n_clusters=num).fit(feat)  

The thing I am confused about is how I get clusters of words such as

cluster 0    WhatsApp, update,biggest     cluster 1    history,biggest ,world's     etc.  
https://stackoverflow.com/questions/65754763/get-clusters-of-words-using-kmeans-and-tf-idf January 17, 2021 at 05:10AM

没有评论:

发表评论