recbole.data.utils

recbole.data.utils.create_dataset(config)[source]

Create dataset according to config['model'] and config['MODEL_TYPE']. If config['dataset_save_path'] file exists and its config of dataset is equal to current config of dataset. It will return the saved dataset in config['dataset_save_path'].

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)[source]

Split the dataset by config['[valid|test]_eval_args'] and create training, validation and test dataloader.

Note

If we can load split dataloaders by load_split_dataloaders(), we will not create new split dataloaders.

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.

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: Literal['train', 'valid', 'test', 'evaluation'])[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 4 values: ‘train’, ‘valid’, ‘test’ or ‘evaluation’. Notes: ‘evaluation’ has been deprecated, please use ‘valid’ or ‘test’ instead.

Returns

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

Return type

type

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

Load split dataloaders if saved dataloaders exist and their config of dataset are the same as current config of dataset.

Parameters

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

Returns

The split dataloaders.

Return type

dataloaders (tuple of AbstractDataLoader or None)

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.