import scipy.spatial.distance as dist
import numpy as np
import timeit
X = np.random.random((1000, 1000))
def run():
c = dist.cdist(X, X, 'euclidean')
return c
times = timeit.Timer(run).timeit(number=100)
print times
Elapsed time: 108.59s
X = rand(1000,1000);
tic;
for n = 1:100
c = pdist2(X, X, 'euclidean');
end
toc
Elapsed Time: 108.66s
using Distances
tic()
X = rand(1000, 1000)
for i = 1:100
R = pairwise(Euclidean(), X, X)
end
toc()
Elapsed Time: 5.69s