scikit-learn/scikit-learn — Issue #392: supplying a matrix (as opposed to an array) to clustering algorithms will fail on normsquared computations
Author: biolauncher
Created: 2011-10-12 15:24:00+00:00
State: open

I have noticed in many places to calculate the square of an array the following idiom is used:

a **= 2

this will fail if a is a matrix, more robust (in this case) is to use:

np.exp2(a)

but when calculating sums worse occurs for matrices:

np.sum(a, axis=1).shape != np.sum(m, axis=1)

this breaks (at least) the euclideanmetric which expects (1, n) shaped normsquares

So none of this is matrix safe. Are matrices not then array-like?