hierarchical-clustering

Using cophenetic distance to choose best linkage method?

Using cophenetic distance to choose best linkage method? Question: I have the dataset that generates the following code. X_moons, y_moons = datasets.make_moons(n_samples=1000, noise=.07, random_state=42) The case is that I would like to make a dendrogram (bottom-up) in Python and I must select a linkage criterion. If you consult the documentation of the function you can …

Total answers: 1

Matching up the output of scipy linkage() and dendrogram()

Matching up the output of scipy linkage() and dendrogram() Question: I’m drawing dendrograms from scratch using the Z and P outputs of code like the following (see below for a fuller example): Z = scipy.cluster.hierarchy.linkage(…) P = scipy.cluster.hierarchy.dendrogram(Z, …, no_plot=True) and in order to do what I want, I need to match up a given …

Total answers: 2

In python hierarchical clustering by pairwise distances, how can I cut on specific distances and get clusters and list of members of each cluster?

In python hierarchical clustering by pairwise distances, how can I cut on specific distances and get clusters and list of members of each cluster? Question: I have pairwise distances data like this: distances = { (‘DN1357_i2’, ‘DN1357_i5’): 1.0, (‘DN1357_i2’, ‘DN10172_i1’): 28.0, (‘DN1357_i2’, ‘DN1357_i1’): 8.0, (‘DN1357_i5’, ‘DN1357_i1’): 2.0, (‘DN1357_i5’, ‘DN10172_i1’): 34.0, (‘DN1357_i1’, ‘DN10172_i1’): 38.0, } So …

Total answers: 2

To determine the optimal k-mean for given dataset using python

To determine the optimal k-mean for given dataset using python Question: I am pretty new to python and the clusttering stuff. Right now I have a task to analyze a set of data and determine its optimal Kmean by using elbow and silhouette method. As shown in the picture, my dataset has three features, one …

Total answers: 1

Custom cluster colors of SciPy dendrogram in Python (link_color_func?)

Custom cluster colors of SciPy dendrogram in Python (link_color_func?) Question: I want to color my clusters with a color map that I made in the form of a dictionary (i.e. {leaf: color}). I’ve tried following https://joernhees.de/blog/2015/08/26/scipy-hierarchical-clustering-and-dendrogram-tutorial/ but the colors get messed up for some reason. The default plot looks good, I just want to assign …

Total answers: 4

Newick tree representation to scipy.cluster.hierarchy linkage matrix format

Newick tree representation to scipy.cluster.hierarchy linkage matrix format Question: I have a set of genes which have been aligned and clustered based on DNA sequences, and I have this set of genes in a Newick tree representation (https://en.wikipedia.org/wiki/Newick_format). Does anyone know how to convert this format to the scipy.cluster.hierarchy.linkage matrix format? From the scipy docs …

Total answers: 3

Tutorial for scipy.cluster.hierarchy

Tutorial for scipy.cluster.hierarchy Question: I’m trying to understand how to manipulate a hierarchy cluster but the documentation is too … technical?… and I can’t understand how it works. Is there any tutorial that can help me to start with, explaining step by step some simple tasks? Let’s say I have the following data set: a …

Total answers: 1

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

Use Distance Matrix in scipy.cluster.hierarchy.linkage()? Question: I have a distance matrix n*n M where M_ij is the distance between object_i and object_j. So as expected, it takes the following form: / 0 M_01 M_02 … M_0n | M_10 0 M_12 … M_1n | | M_20 M_21 0 … M2_n | | … | M_n0 M_n2 …

Total answers: 2