GGNN代码讲解

数据处理 preprocess.py

data OrderedDict
([('session_id', '1638'), ('user_id', 'NA'), ('item_id', '34157'), ('timeframe', '113380'), ('eventdate', '2016-04-25')])

sess_clicks {'1': [('81766', 526309), ('31331', 1031018), ('32118', 243569), ('9654', 75848), ('32627', 1112408)]}
a={1:'a',5:'d'}
print(a)
print(a.items())
print(list(a))

>>>
{1: 'a', 5: 'd'}
dict_items([(1, 'a'), (5, 'd')])
[1, 5]


data长这样,就是那两个东西合起来
287], [272, 287, 287], [272, 287], [272]], [3, 2, 5, 7, 9, 9, 11, 11, 11, 13, 14, 18, 17, 16, 19, 20, 21, 23, 23

tr_seqs
[[1, 2], [1], [4], [6], [8, 9], [8], [10, 11, 11], [10, 11], [10], [12], [14], [15, 16, 17], [272, 287, 287, 287, 271], [272, 287, 287, 287], [272, 287, 287], [272, 287], [272]]
tr_labs
[3, 2, 5, 7, 9, 9, 11271, 287, 287, 287]



上边两个,生成下边两个

csv.DictReader
https://blog.csdn.net/tomatomas/article/details/81005503
sorted
https://www.runoob.com/python/python-func-sorted.html
Python3 zip() 函数
https://www.runoob.com/python3/python3-func-zip.html

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 传送门 测试开发知识点(一)测试开发知识点(二)测试开发知识点(三)测试开发知识点(四)测试开发知识点(五) Li...
    测试老杨阅读 1,808评论 0 6
  • (转)Python 面试中可能会被问到的问题 原标题:10 家公司 Python 面试题总结 1 简述解释型和编译...
    耀魄天蝎阅读 248评论 0 0
  • 1. Python的hello-world: print ("Hello, Python!")、 完了 摇就完事儿...
    LunarShade阅读 1,602评论 0 0
  • abs() 函数 描述 abs() 函数返回数字的绝对值。 语法 以下是 abs() 方法的语法: abs( x ...
    时光是座城阅读 513评论 0 2
  • 昨天晚上拜读了这篇文章,感触极深,特此推荐给朋友 总有一些人,你活得青春无敌、你过得光鲜亮丽,却看不见你身后,默默...
    悟道修行阅读 816评论 3 2