To solve a problem I need manhattan distances between all the vectors. I tried sklearn.metrics.pairwise_distances
but the size was too large, so in order to decrease memory footprint I used scipy.spatial.distance.pdist
to get the condensed 1D
matrix of distances.
I used below formula:
index = diagonalShape*(diagonalShape-1)/2 - (diagonalShape-i)*(diagonalShape-i-1)/2 + j - i - 1
to calculate the index of the 1D
matrix to get the distance value of ij
.
I've observed that for many entries the distances are different form scipy
and sklearn
. Why this is so when the formula used for calculating cityblock distances is same for both the libraries?