I want to compute the correlation distance between two vectors/arrays. What function should I use for it?

+1 vote

Best answer

The **correlation()** function of *scipy* can be used to compute the correlation distance between two numpy arrays or list.

Here is an example:

>>> from scipy.spatial.distance import correlation

>>> import numpy as np

>>> a=np.array([1,0,0,1,1,0,0,0,1])

>>> b=np.array([1,0,0,1,1,0,0,1,1])

>>>correlation(a,b)

0.20000000000000007