Re: Use Distance Matrix in scipy.cluster.hierarchy.linkage()?
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.
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?