hierarchical clustering doesn't work as expected

I have a precomputed distance matrix.

I'm trying to do an hierarchical clustering using scipy:

from scipy.cluster.hierarchy import fcluster, linkage, cut_tree,fcluster

clust = fcluster(z, 4, criterion='maxclust')
print(clust)


The problem is that, most of the labels ends up in one group - Why?

By the way, I tried to use AgglomerativeClustering as well but I got similar results.

ds is the precomputed distance matrix. I'm using DTW, a distance metric for time series analysis.

I uploaded ds.csv to here.

Also, here's an heatmap which forms interesting lines (I don't really know how to interpret this currently)

• As far as I remember this can be related to the specific method used to merge instances; did you try another value instead of criterion='maxclust'? – Erwan Oct 22 '19 at 16:56

Judging from your plot, it's probably a half-filled similarity matrix instead. And it likely is not in the required form for linkage.