kayzhu / LSHash

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

Is there any way to also obtain the indices in result of query? #25

Closed mehrrsaa closed 5 years ago

mehrrsaa commented 6 years ago

Hi,

I was wondering if there is any way to also obtain the indices of the results of a query since a lot of times we may need to for example go back to some sort of embedding and see what element it is representing.

Thank you so much for the amazing work!

andreArtelt commented 6 years ago

Hi mehrrsaa,

you can add the index to the extra_data argument of the index function. For instance:

        for i in range(0, X.shape[0]):
            self.model.index(X[i,:], extra_data=(i))

where i add all rows of a matrix to the hash table. I also add the the associated index i to each element (row). The additional data in extra_data is attached to the results returned by the function query.

Best wishes, André

mehrrsaa commented 5 years ago

Thank you for the explanation!