deepcarskit.data

deepcarskit.data.utils

deepcarskit.data.utils.create_dataset(config)

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

Args:

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

Returns:

Dataset: Constructed dataset.

deepcarskit.data.utils.create_samplers(config, dataset, built_datasets)

Create sampler for training, validation and testing.

Args:

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:
tuple:
  • train_sampler (AbstractSampler): The sampler for training.

  • valid_sampler (AbstractSampler): The sampler for validation.

  • test_sampler (AbstractSampler): The sampler for testing.

deepcarskit.data.utils.data_preparation(config, dataset, save=False)

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

Args:

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:
tuple:
  • train_data (AbstractDataLoader): The dataloader for training.

  • valid_data (AbstractDataLoader): The dataloader for validation.

  • test_data (AbstractDataLoader): The dataloader for testing.

deepcarskit.data.utils.get_dataloader(config, phase)

Return a dataloader class according to config and phase.

Args:

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:

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

deepcarskit.data.utils.get_used_ids(config, dataset)
Returns:

dict: Used item_ids is the same as positive item_ids. Key is phase, and value is a numpy.ndarray which index is user_id, and element is a set of item_ids.

deepcarskit.data.utils.load_split_dataloaders(saved_dataloaders_file)

Load split dataloaders.

Args:

saved_dataloaders_file (str): The path of split dataloaders.

Returns:

dataloaders (tuple of AbstractDataLoader): The split dataloaders.

deepcarskit.data.utils.save_split_dataloaders(config, dataloaders)

Save split dataloaders.

Args:

config (Config): An instance object of Config, used to record parameter information. dataloaders (tuple of AbstractDataLoader): The split dataloaders.

deepcarskit.data.create_dataset(config)

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

Args:

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

Returns:

Dataset: Constructed dataset.

deepcarskit.data.data_preparation(config, dataset, save=False)

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

Args:

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:
tuple:
  • train_data (AbstractDataLoader): The dataloader for training.

  • valid_data (AbstractDataLoader): The dataloader for validation.

  • test_data (AbstractDataLoader): The dataloader for testing.

deepcarskit.data.load_split_dataloaders(saved_dataloaders_file)

Load split dataloaders.

Args:

saved_dataloaders_file (str): The path of split dataloaders.

Returns:

dataloaders (tuple of AbstractDataLoader): The split dataloaders.

deepcarskit.data.save_split_dataloaders(config, dataloaders)

Save split dataloaders.

Args:

config (Config): An instance object of Config, used to record parameter information. dataloaders (tuple of AbstractDataLoader): The split dataloaders.