recbole.data.utils

class recbole.data.utils.DLFriendlyAPI[source]

Bases: object

A Decorator class, which helps copying Dataset methods to DataLoader.

These methods are called DataLoader Friendly APIs.

E.g. if train_data is an object of DataLoader, and num() is a method of Dataset, Cause it has been decorated, num() can be called directly by train_data.

See the example of set() for details.

dataloader_apis

Register table that saves all the method names of DataLoader Friendly APIs.

Type

set

set()[source]

Example

from recbole.data.utils import dlapi

@dlapi.set()
def dataset_meth():
    ...
recbole.data.utils.create_dataset(config)[source]

Create dataset according to config['model'] and config['MODEL_TYPE'].

Parameters

config (Config) – An instance object of Config, used to record parameter information.

Returns

Constructed dataset.

Return type

Dataset

recbole.data.utils.data_preparation(config, dataset, save=False)[source]

Split the dataset by config['eval_setting'] and call dataloader_construct() to create corresponding dataloader.

Parameters
  • config (Config) – An instance object of Config, used to record parameter information.

  • dataset (Dataset) – An instance object of Dataset, which contains all interaction records.

  • save (bool, optional) – If True, it will call save_datasets() to save split dataset. Defaults to False.

Returns

  • train_data (AbstractDataLoader): The dataloader for training.

  • valid_data (AbstractDataLoader): The dataloader for validation.

  • test_data (AbstractDataLoader): The dataloader for testing.

Return type

tuple

recbole.data.utils.get_data_loader(name, config, neg_sample_args)[source]

Return a dataloader class according to config and eval_setting.

Parameters
  • name (str) – The stage of dataloader. It can only take two values: ‘train’ or ‘evaluation’.

  • config (Config) – An instance object of Config, used to record parameter information.

  • neg_sample_args (dict) – Settings of negative sampling.

Returns

The dataloader class that meets the requirements in config and eval_setting.

Return type

type

recbole.data.utils.load_split_dataloaders(saved_dataloaders_file)[source]

Load split dataloaders.

Parameters

saved_dataloaders_file (str) – The path of split dataloaders.

Returns

The split dataloaders.

Return type

dataloaders (tuple of AbstractDataLoader)

recbole.data.utils.save_split_dataloaders(config, dataloaders)[source]

Save split dataloaders.

Parameters
  • config (Config) – An instance object of Config, used to record parameter information.

  • dataloaders (tuple of AbstractDataLoader) – The split dataloaders.