2.6数据-paddlepaddle数据集movielens

Movielens 1-M数据集
Movielens 1-M数据集是由GroupLens Research采集的6000个用户对4000个电影的的100万个评级。 该模块将从 http://files.grouplens.org/datasets/movielens/ml-1m.zip 下载Movielens 1-M数据集,并将训练集和测试集解析为paddle reader creator。


paddle.dataset.movielens:https://www.paddlepaddle.org.cn/documentation/docs/zh/api_cn/data/dataset_cn/movielens_cn.html


import paddle
import paddle.fluid as fluid
import paddle.dataset.movielens as movielens

# 获取电影标题词典
title_dict=movielens.get_movie_title_dict()
'''
[======================================            ]vielens/ml-1m.zip not found, downloading http://files.grouplens.org/datasets/movielens/ml-1m.zip
'''
title_dict
'''
{'disturbing': 0,
 'demonio)': 1,
 'great': 2,
 '(alice': 3,
 'chuck': 4,
 'eight)': 5,
 ...
}
'''

len(title_dict.keys()),list(title_dict.keys())[0],list(title_dict.keys())[-1]
# 5174, 'cowboy', 'quartermain'

# 电影ID的最大值
movielens.max_movie_id() # 3952

# 用户ID的最大值
movielens.max_user_id() # 6040

# 职业ID的最大值
movielens.max_job_id() # 20

# 电影类别词典
categories_dict=movielens.movie_categories()
'''
{'Thriller': 0,
 'Sci-Fi': 1,
 'Crime': 2,
 'Documentary': 3,
 'Musical': 4,
 "Children's": 5,
 'Adventure': 6,
 'Action': 7,
 'Horror': 8,
 'War': 9,
 'Film-Noir': 10,
 'Western': 11,
 'Drama': 12,
 'Romance': 13,
 'Animation': 14,
 'Comedy': 15,
 'Mystery': 16,
 'Fantasy': 17}
'''

# 用户信息词典
user_info_dict=movielens.user_info()
# 查看一个UserInfo对象
user_info_dict[1],user_info_dict[1].index,user_info_dict[1].job_id
# <UserInfo id(1), gender(F), age(1), job(10)>, 1, 10

原文地址:https://www.cnblogs.com/onenoteone/p/12441674.html