Why does scipy.cluster.hierarchy.linkage require a metric?

We have to go through the distance matrix, so there should be no need to calculate any additional distances, right? What am I missing?

Documentation here: http://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.cluster.hierarchy.linkage.html

+5
source share
1 answer

The linkage function does not need the metric argument; it cancels the transmission of your original observations instead of the distance matrix .

From the published link

y: ndarray
[...] Alternatively, a collection of m observation vectors in n dimensions can be transmitted as an array m by n.

The linkage function checks if you passed a valid distance matrix, presumably using is_valid_y / is_valid_dm - and if not, it will first apply pdist with the metric you specify (and the Euclidean metric if nothing is specified).

+2
source

Source: https://habr.com/ru/post/1200141/


All Articles