recbole.data.utils

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.create_samplers(config, dataset, built_datasets)[source]

Create sampler for training, validation and testing.

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.

  • built_datasets (list of Dataset) – A list of split Dataset, which contains dataset for training, validation and testing.

Returns

  • train_sampler (AbstractSampler): The sampler for training.

  • valid_sampler (AbstractSampler): The sampler for validation.

  • test_sampler (AbstractSampler): The sampler for testing.

Return type

tuple

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

Split the dataset by config['eval_args'] and create training, validation and test 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_dataloader(config, phase)[source]

Return a dataloader class according to config and phase.

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

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

Returns

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

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.