The spearmanr distance currently returns the actual Spearman rank-correlation coefficient, which behaves like a similarity measure rather than a dissimilarity measure. I believe this is not what NNDescent expects. Rather than using the numpy correlation matrix function, we can use the correlation distance after computing the rank transformation. Making this change also resolves a problem where spearmanr would return nan when both input vectors were identical.
The
spearmanr
distance currently returns the actual Spearman rank-correlation coefficient, which behaves like a similarity measure rather than a dissimilarity measure. I believe this is not whatNNDescent
expects. Rather than using the numpy correlation matrix function, we can use thecorrelation
distance after computing the rank transformation. Making this change also resolves a problem wherespearmanr
would returnnan
when both input vectors were identical.