kayzhu / LSHash

A fast Python implementation of locality sensitive hashing.
MIT License
660 stars 158 forks source link

Any know how to change or add distance function? #32

Open hsingchenlee opened 4 years ago

hsingchenlee commented 4 years ago

lshash.py line 298 like that:
@staticmethod def euclidean_dist(x, y): """ This is a hot function, hence some optimizations are made. """ diff = np.array(x)-y return np.sqrt(np.dot(diff, diff))

I change the diff like that:
diff = np.array(x)-y change to np.array(x)-(mean(x)-mean(y))-y

But when I print(lsh.query([3,4,5,3,4,5,3,4],distance_func="euclidean")) Compare to the origin euclidean_dist , the result is same . It seems that it's not a correct method to change distance function. Anyone could tell me how to change distance function? Thanks a lot!