Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

We're required to pass a 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

like image 251
elplatt Avatar asked Oct 21 '22 03:10

elplatt


1 Answers

The linkage function does not need the metric argument, unlees you pass in your original observations instead of a distance matrix.

From your posted link

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

The linkage function checks, if you passed in a valid distance matrix - presumable using is_valid_y / is_valid_dm - and if not it will first apply pdist with the metric you have specified (and euclidean metric if nothing has been specified).

like image 104
embert Avatar answered Nov 15 '22 03:11

embert