简体   繁体   中英

Cluster two features in Python

I have two sparse scipy matrix's, title and paragraph whose dimensions are (284,183) and (284,4195) respectively. Each row of both matrix's are features from one instance of my dataset. I wish to cluster these without a predefined number of clusters and then plot them.

I also have an array, Y that relates to each row. (284,1) . One class is represented by 0, the other by 1. I would like to color the points using this. How can I do this using Python?

You can use the skikit-learn Affinity propagation or Mean-shift libraries for clustering. Those algorithms will output a number of clusters and centers. To use the Y seems to be a different question because you can't plot the multi dimensional point on a 3D plane unless you do some import some other libraries.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM