Skip to content

Instantly share code, notes, and snippets.

@santhoshhari
Created July 4, 2018 05:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save santhoshhari/9962431c9a8055365f9d46a773e78d47 to your computer and use it in GitHub Desktop.
Save santhoshhari/9962431c9a8055365f9d46a773e78d47 to your computer and use it in GitHub Desktop.
class LSH:
def __init__(self, num_tables, hash_size, inp_dimensions):
self.num_tables = num_tables
self.hash_size = hash_size
self.inp_dimensions = inp_dimensions
self.hash_tables = list()
for i in range(self.num_tables):
self.hash_tables.append(HashTable(self.hash_size, self.inp_dimensions))
def __setitem__(self, inp_vec, label):
for table in self.hash_tables:
table[inp_vec] = label
def __getitem__(self, inp_vec):
results = list()
for table in self.hash_tables:
results.extend(table[inp_vec])
return list(set(results))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment