プリンキピア

第21章推薦システム

21.7.4. Load the MovieLens 100K dataset21.7.4 MovieLens 100Kのデータセットを読み込む

Afterwards, we read and split the MovieLens 100K dataset in sequence-aware mode and load the training data with sequential dataloader implemented above.
英語のヒント
その後、MovieLens 100Kのデータセットを読み込んで系列を考慮したモードで分割し、上で実装した系列のデータローダで訓練データを読み込む。
TARGET_NUM, L, batch_size = 1, 5, 4096
df, num_users, num_items = d2l.read_data_ml100k()
train_data, test_data = d2l.split_data_ml100k(df, num_users, num_items,
                                              'seq-aware')
users_train, items_train, ratings_train, candidates = d2l.load_data_ml100k(
    train_data, num_users, num_items, feedback="implicit")
users_test, items_test, ratings_test, test_iter = d2l.load_data_ml100k(
    test_data, num_users, num_items, feedback="implicit")
train_seq_data = SeqDataset(users_train, items_train, L, num_users,
                            num_items, candidates)
train_iter = gluon.data.DataLoader(train_seq_data, batch_size, True,
                                   last_batch="rollover",
                                   num_workers=d2l.get_dataloader_workers())
test_seq_iter = train_seq_data.test_seq
train_seq_data[0]
Downloading ../data/ml-100k.zip from https://files.grouplens.org/datasets/movielens/ml-100k.zip...
[22:02:15] ../src/storage/storage.cc:196: Using Pooled (Naive) StorageManager for CPU
(array(0, dtype=int32),
 array([241., 170., 110., 255.,   4.]),
 array([101.]),
 709)
The training data structure is shown above. The first element is the user identity, the next list indicates the last five items this user liked, and the last element is the item this user liked after the five items.
英語のヒント
訓練データの構造は上に示したとおりである。最初の要素は利用者のIDで、次のリストはこの利用者が好んだ最後の5個のアイテムを示し、最後の要素はこの利用者がその5個のアイテムの後に好んだアイテムである。