-1
$\begingroup$

Here is the reproducable code with dataset used

`from scipy.cluster import hierarchy

import matplotlib.pyplot as plt

ytdist = np.array([662., 877., 255., 412., 996., 295., 468., 268.,400., 754., 564., 138., 219., 869., 669.])

Z = hierarchy.linkage(ytdist, 'single')

plt.figure()

dn = hierarchy.dendrogram(Z)

Now plot in given axes, improve the color scheme and use both vertical and horizontal orientations:

hierarchy.set_link_color_palette(['m', 'c', 'y', 'k'])

fig, axes = plt.subplots(1, 2, figsize=(8, 3))

dn1 = hierarchy.dendrogram(Z, ax=axes[0],

above_threshold_color='y',orientation='top')

dn2 = hierarchy.dendrogram(Z, ax=axes1, above_threshold_color='#bcbddc',orientation='right')

hierarchy.set_link_color_palette(None) # reset to default after use

plt.show()`

Once I execute the above plot I got a plot below, I request you to assist me with interpretation of the axis !!! hierachical clustering plot

My doubts are: 1. When the dataset are in the range of 138 to 996, Why the plot axis varies from 0 to 300 ? 2. What does 0,1,2,3,4,5 on the plot represent ?

$\endgroup$
0
$\begingroup$
  1. The height is a distance, not absolute coordinates.
  2. The labels 0,1,2... are row numbers.
$\endgroup$
  • $\begingroup$ Thank you. 1. Height is the distance of what meaning which distance it refers to? What can this be compared with for this dataset ? 2. Also there is only 1 row How does the ytdist = np.array([662., 877., 255., 412., 996., 295., 468., 268.,400., 754., 564., 138., 219., 869., 669.]) has row number from 0 to 5 $\endgroup$ – Abhishek May 3 '17 at 8:35
  • $\begingroup$ See the documentation of hierarchy.linkage. This array represents a 1d compressed distance matrix. 6 choose 2 = 15. $\endgroup$ – Has QUIT--Anony-Mousse May 3 '17 at 9:23
  • $\begingroup$ I tried to understand from the documentation. This statement is unclear to me since ages If y is a 1d compressed distance matrix, then y must be a (n 2) sized vector where n is the number of original observations paired in the distance matrix. $\endgroup$ – Abhishek May 3 '17 at 10:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.