Skip to content

Instantly share code, notes, and snippets.

@singhrahuldps
Created June 1, 2019 04:53
Show Gist options
  • Save singhrahuldps/a23de948b97aad5d0d40c45aafbca1e4 to your computer and use it in GitHub Desktop.
Save singhrahuldps/a23de948b97aad5d0d40c45aafbca1e4 to your computer and use it in GitHub Desktop.
# get list of unique user ids
users = sorted(list(set(ratings[user_col].values)))
# get list of unique item ids
items = sorted(list(set(ratings[item_col].values)))
# generate dict of correponding indexes for the user ids
user2idx = list_2_dict(users)
# generate dict of correponding indexes for the item ids
item2idx = list_2_dict(items)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment