title: How to compute similarities between arrays?
body: <p>I am trying to compute similarity between two samples.
  The python functions <code>sklearn.metrics.pairwise.cosine_similarity</code> and
  <code>scipy.spatial.distance.cosine</code> return results that I am not satisfied with. For example:</p>
  <ul>
  <li><p>In the following I would have expected 0.0%, because the two samples do not have identical samples.</p>
  <pre><code> tt1 = [1, 16, 4, 21]
   tt2 = [5, 17, 3, 22]
  
   from scipy import spatial
   res = 1-spatial.distance.cosine(tt1, tt2)
   print(res)
   0.9893593529663931
  </code></pre>
  </li>
  <li><p>I would have expected 0.25% of similarity because only a single sample, the first one (1), in both arrays are the same.</p>
  <pre><code> tt1 = [1, 16, 4, 21]
   tt2 = [1, 17, 3, 22]
  
   from scipy import spatial
   res = 1-spatial.distance.cosine(tt1, tt2)
   print(res)
   0.9990578001169402
  </code></pre>
  </li>
  <li><p>In the same way we have the following where I would expect 0.5% was expected. Two identical samples (1 and 16)</p>
  <pre><code> tt1 = [1, 16, 4, 21]
   tt2 = [1, 16, 3, 22]
   res = 0.9989359418266097
  </code></pre>
  </li>
  <li><p>Here 0.75% was expected. Three identical samples (1, 16 and 4)</p>
  <pre><code> tt1 = [1, 16, 4, 21]
   tt2 = [1, 16, 4, 22]
   res = 0.9997474232272052
  </code></pre>
  </li>
  </ul>
  <p>Is there a way in python to achieve those expected results ?</p>