I'm new to scikit.
I can't find an example using a precomputed distance matrix in Scikit KMeans.
Could anybody shed a light now this, better with an example?
Sklearn Kmeans uses the Euclidean distance. It has no metric parameter.
K-Means uses euclidean distance, as the default distance metric, for clustering.
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.
Hey, to my knowledge, the R function hclust is able to generate clustering from a distance matrix as input such as the matrix produced by the dist function in R.
Scikit-learn does not allow you to pass in a custom (precomputed) distance matrix. It can precompute Euclidean distance matrix to speed-up the process, but there's no way to use your own one without hacking the source.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With