sklearn AgglomerativeClustering ValueError: Precomputed metric requires shape (n_queries, n_indexed)

Viewed 289

So I am currently trying to use AgglomerativeClustering with a connectivity matrix from sklearn NearestNeighbors and a precomputed distance matrix as X.

clustering = AgglomerativeClustering(affinity="precomputed", connectivity=nbrs, linkage="single",distance_threshold=0, n_clusters=None).fit_predict(dist_mtrx_dense)

I get the following error when I try to fit my distance matrix

ValueError: Precomputed metric requires shape (n_queries, n_indexed). Got (1, 11200) for 1 indexed.

The shape of the connectivity matrix is (11200, 11200) and for the distance matrix (11200, 11200). I also already tried to delete the diagonal from the distance matrix but still got the same error with got (1, 11199)

0 Answers
Related