Surprise读取数据报错:Impossible to parse line. Check the line_format and sep parameters.
# popular_music_suprise_format.txt,
# 格式:69466470,29019227,1.0,1300000
# 69466470,5093684,1.0,1300000
file_path = os.path.expanduser('../data/popular_music_suprise_format.txt')
# user item rating timestamp(用户id 项目id 评分 时间戳)
reader = Reader(line_format='user item rating timestamp', sep=',')
# 从文件读取数据
music_data = Dataset.load_from_file(file_path,reader=reader)
print('music_data:',music_data)
sys.exit(37)
【报错】:
IndexError: list index out of range
During handling of the above exception, another exception occurred:
raise ValueError('Impossible to parse line. Check the line_format' ValueError: Impossible to parse line. Check the line_format and sep parameters.
源码:readers
def parse_line(self, line):
line = line.split(self.sep)
try:
if self.with_timestamp:
uid, iid, r, timestamp = (line[i].strip()
for i in self.indexes)
else:
uid, iid, r = (line[i].strip()
for i in self.indexes)
timestamp = None
except IndexError:
raise ValueError('Impossible to parse line. Check the line_format'
' and sep parameters.')
return uid, iid, float(r) + self.offs