kayzhu / LSHash

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

lshash.query() returning empty values #10

Closed mansilla closed 3 years ago

mansilla commented 8 years ago

Hi everyone. Don't know whats going on but my index is querying only over the points I have already submitted. For example

>>> import numpy as np
>>> import lshash
>>> lsh = lshash.LSHash(100,100)
>>> sample = np.zeros(100)
>>> sample[13]=1
>>> sample[43]=1
>>> sample[73]=1
>>> lsh.index(sample)
>>> sample[93]=1
>>> lsh.index(sample)
>>> sample = np.zeros(100)
>>> sample[33]=1
>>> sample[32]=1
>>> lsh.index(sample)
>>> sample[33]=0
>>> sample[93]=1
>>> lsh.query(sample)
[]
>>> sample = np.zeros(100)
>>> sample[33]=1
>>> sample[32]=1
>>> lsh.query(sample)
[((0.0, 0.0, 0.0, ..., 0.0, 0.0), 0.0)]
>>>

I am doing something wrong?

DanVane commented 6 years ago

i think it because the buckets your query located have no samples. Actually, there are 2^b buckets in one table. Try to add more samples and make the hash codes smaller.