title: What does sklearn's pairwise_distances with metric='correlation' do?
body: <p>I've put different values into this function and observed the output. But I can't find a predictable pattern in what is being outputed.</p>
  
  <p>Then I tried digging through the <a href="https://github.com/scikit-learn/scikit-learn/blob/7b136e9/sklearn/metrics/pairwise.py#L1316" rel="nofollow noreferrer">function</a> itself, but its confusing because it can do a number of different calculations.</p>
  
  <p><strong>According to the <a href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.pairwise_distances.html" rel="nofollow noreferrer">Docs</a>:</strong> </p>
  
  <pre><code>Compute the distance matrix from a vector array X and optional Y.
  </code></pre>
  
  <p>I see it returns a matrix of height and width equal to the number of nested lists inputted, implying that it is comparing each one. </p>
  
  <p>But otherwise I'm having a tough time understanding what its doing and where the values are coming from.</p>
  
  <p><strong>Examples I've tried:</strong></p>
  
  <pre><code>pairwise_distances([[1]], metric='correlation')
  &gt;&gt;&gt; array([[0.]])
  
  pairwise_distances([[1], [1]], metric='correlation')
  &gt;&gt;&gt; array([[ 0., nan],
  &gt;&gt;&gt;        [nan,  0.]])
  
  # returns same as last input although input values differ
  pairwise_distances([[1], [2]], metric='correlation')
  &gt;&gt;&gt; array([[ 0., nan],
  &gt;&gt;&gt;        [nan,  0.]])
  
  pairwise_distances([[1,2], [1,2]], metric='correlation')
  &gt;&gt;&gt; array([[0.00000000e+00, 2.22044605e-16],
  &gt;&gt;&gt;        [2.22044605e-16, 0.00000000e+00]])
  
  # returns same as last input although input values differ
  # I incorrectly expected more distance because input values differ more
  pairwise_distances([[1,2], [1,3]], metric='correlation')
  &gt;&gt;&gt; array([[0.00000000e+00, 2.22044605e-16],
  &gt;&gt;&gt;       [2.22044605e-16, 0.00000000e+00]])
  
  </code></pre>
  
  <p><strong>Computing correlation distance with Scipy</strong> </p>
  
  <p>I don't understand where the sklearn <code>2.22044605e-16</code> value is coming from if scipy returns <code>0.0</code> for the same inputs.</p>
  
  <pre><code># Scipy
  import scipy
  scipy.spatial.distance.correlation([1,2], [1,2])
  &gt;&gt;&gt; 0.0
  
  # Sklearn
  pairwise_distances([[1,2], [1,2]], metric='correlation')
  &gt;&gt;&gt; array([[0.00000000e+00, 2.22044605e-16],
  &gt;&gt;&gt;        [2.22044605e-16, 0.00000000e+00]])
  </code></pre>
  
  <p>I'm not looking for a high level explanation but an example of how the numbers are calculated.</p>