Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Plot the Results of Text K-Means Clustering?

I am using the example code provided here to implement k-means clustering. I wish to plot the result on a graph to understand the output better. How do I go about it?

I find it a little difficult to understand the plotting code provided in some places.

like image 759
minks Avatar asked Dec 03 '25 15:12

minks


1 Answers

Looking at the page to which you linked, it seems that the particular clustering scheme you use starts by mapping the words into a high dimensional space, e.g.,

HashingVectorizer hashes word occurrences to a fixed dimensional space

So, from this point, your question is how to project a high dimensional space onto 2D. After all, if you can do this, then you can just plot the points corresponding to words in 2D, and color the points according to their cluster number.

There are several ways to project a high dimensional space onto 2D. Perhaps the most intuitive one is PCA (which is the first in the link just above).

like image 176
Ami Tavory Avatar answered Dec 06 '25 03:12

Ami Tavory



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!