Surprise读取数据报错:Impossible to parse line. Check the line_format and sep parameters.

weixin_38060792 2019-06-23 04:03:46
# 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
...全文
269 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

476

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧