recbole.data.sequential_dataset

class recbole.data.dataset.sequential_dataset.SequentialDataset(config)[source]

Bases: recbole.data.dataset.dataset.Dataset

SequentialDataset is based on Dataset, and provides augmentation interface to adapt to Sequential Recommendation, which can accelerate the data loader.

max_item_list_len

Max length of historical item list.

Type

int

item_list_length_field

Field name for item lists’ length.

Type

str

build()[source]

Processing dataset according to evaluation setting, including Group, Order and Split. See EvalSetting for details.

Parameters

eval_setting (EvalSetting) – Object contains evaluation settings, which guide the data processing procedure.

Returns

List of built Dataset.

Return type

list

data_augmentation()[source]

Augmentation processing for sequential dataset.

E.g., u1 has purchase sequence <i1, i2, i3, i4>, then after augmentation, we will generate three cases.

u1, <i1> | i2

(Which means given user_id u1 and item_seq <i1>, we need to predict the next item i2.)

The other cases are below:

u1, <i1, i2> | i3

u1, <i1, i2, i3> | i4

inter_matrix(form='coo', value_field=None)[source]

Get sparse matrix that describe interactions between user_id and item_id. Sparse matrix has shape (user_num, item_num). For a row of <src, tgt>, matrix[src, tgt] = 1 if value_field is None, else matrix[src, tgt] = self.inter_feat[src, tgt].

Parameters
  • form (str, optional) – Sparse matrix format. Defaults to coo.

  • value_field (str, optional) – Data of sparse matrix, which should exist in df_feat. Defaults to None.

Returns

Sparse matrix in form coo or csr.

Return type

scipy.sparse