I have two np.ndarray
s, data
with shape (8000, 500)
and sample
with shape (1, 500)
.
What I am trying to achieve is measure various types of metrics between every row in data
to sample
.
When using from sklearn.metrics.pairwise.cosine_distances
I was able to take advantage of numpy
's broadcasting executing the following line
x = cosine_distances(data, sample)
But when I tried to use the same procedure with scipy.spatial.distance.cosine
I got the error
ValueError: Input vector should be 1-D.
I guess this is a broadcasting issue and I'm trying to find a way to get around it.
My ultimate goal is to iterate over all of the distances available in scipy.spatial.distance
that can accept two vectors and apply them to the data and the sample.
How can I replicate the broadcasting that automatically happens in sklearn
's in my scipy
version of the code?