Skip to content

Instantly share code, notes, and snippets.

@hamilton
Created May 24, 2010 06:12
Show Gist options
  • Save hamilton/411577 to your computer and use it in GitHub Desktop.
Save hamilton/411577 to your computer and use it in GitHub Desktop.
import lsh
lsh_machine = lsh.LSH(assignment_name="example")
# data is a dictionary of the form:
#{user_id: set([item_id1, item_id2, ...]), ...}
# Depending on the input size, training can take a while.
# But it will use all your cores to do so, and will
# automatically cache the data for assignment_name. This
# means you only need to process data once,
# and you can add more as it comes.
lsh_machine.bin_data(data, dims=largest_item_id_number)
# now supply a key and data point:
lsh.near_neighbors(some_user_id, data[some_user_id])
# just like that.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment