Skip to content

Instantly share code, notes, and snippets.

@GabsGear
Created April 15, 2019 15:56
Show Gist options
  • Save GabsGear/e92c0666d16fd61e1a7b032090311afe to your computer and use it in GitHub Desktop.
Save GabsGear/e92c0666d16fd61e1a7b032090311afe to your computer and use it in GitHub Desktop.
import os, io
def read_item_names():
"""Read the u.item file from MovieLens 100-k dataset and returns a
mapping to convert raw ids into movie names.
"""
file_name = (os.path.expanduser('~') +
'/.surprise_data/ml-100k/ml-100k/u.item')
rid_to_name = {}
with io.open(file_name, 'r', encoding='ISO-8859-1') as f:
for line in f:
line = line.split('|')
rid_to_name[line[0]] = line[1]
return rid_to_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment