Skip to content Skip to sidebar Skip to footer

Passing Distance Matrix To K-means Clustering In Sklearn

As per as the sklearn kmeans documentation, it says that k-means requires a matrix of shape=(n_samples, n_features). But I provided a distance matrix of shape=(n_samples,n_samples)

Solution 1:

K-means, as the name indicates, uses means.

Computing the arithmetic mean requires access to the original features, a distance matrix cannot be used.

K-means also does not use pairwise distances. So the distance matrix is useless for this algorithm.

Choose a different algorithm instead, such as hierarchical clustering.

Post a Comment for "Passing Distance Matrix To K-means Clustering In Sklearn"