Quantcast

[SciPy-User] Use Distance Matrix in scipy.cluster.hierarchy.linkage()?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[SciPy-User] Use Distance Matrix in scipy.cluster.hierarchy.linkage()?

Sema Atasever
Dear SciPy list member,

I want to ask you about clustering usign scipy.cluster.hierarchy.

I have a distance matrix n*n M where M_ij is the distance between object_i and object_j. You can see file format in the attachment --> (dm.csv)

I want to cluster these n objects with hierarchical clustering. 

For this purpose i am usign this python code that you can see in the attachment (scipy_code.py) 

I want to ask that how can get clusters values in pdf format or text format and how many clusters did i get and what clusters includes what members?

Thanks in Advance, Best regards.

_______________________________________________
SciPy-User mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user

scipy_python_codes.txt (1K) Download Attachment
dm.csv (930 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Use Distance Matrix in scipy.cluster.hierarchy.linkage()?

kgulliks
Sema,

It is a two step process (at least). Here is an example:

    from scipy.cluster import hierarchy

    Z = hierarchy.linkage(dm, metric='precomputed')
    labels = hierarchy.fcluster(Z, n_clusters, criterion='maxclust')

The labels array will have length n, and will look like [0, 0, 1, 2, 0, ...]. Typically, you have to choose the number of clusters (or some other criterion, see fcluster docs). You can do that by looking at the dendrogram plot with this command, which will make a matplotlib plot:

    hierarchy.dendrogram(Z)  # This has a bunch of useful keyword arguments too.

Happy clustering!
Kevin

On Fri, Feb 24, 2017 at 12:59 AM Sema Atasever <[hidden email]> wrote:
Dear SciPy list member,

I want to ask you about clustering usign scipy.cluster.hierarchy.

I have a distance matrix n*n M where M_ij is the distance between object_i and object_j. You can see file format in the attachment --> (dm.csv)

I want to cluster these n objects with hierarchical clustering. 

For this purpose i am usign this python code that you can see in the attachment (scipy_code.py) 

I want to ask that how can get clusters values in pdf format or text format and how many clusters did i get and what clusters includes what members?

Thanks in Advance, Best regards.
_______________________________________________
SciPy-User mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user
--
Kevin Gullikson
Data Scientist
Spark Cognition


_______________________________________________
SciPy-User mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user
Loading...