Cosine similarity output different for different libraries
<p>I am trying to find the cosine distance between two n-dimensional vectors. I did so by using both scipy and sklearn. Somehow the output of the two libraries are different. I am not able to understand why.</p>

<pre><code>import numpy as np
from scipy import spatial
from sklearn import metrics
a=np.array([1,2,3,4])
b=np.array([2,3,1,4])
X=np.array([a,b])
print spatial.distance.pdist(X,'cosine')[0]
print metrics.pairwise.cosine_similarity(a,b)[0][0]
print metrics.pairwise_distances(np.reshape(a,(1,4)),np.reshape(b,(1,4)),metric = 'cosine')[0][0]
</code></pre>

<p>Output of this code is as follows:</p>

<pre><code>0.1

0.9

0.1
</code></pre>