recpack.scenarios.Scenario

class recpack.scenarios.Scenario(validation=False, seed=None)

Base class for defining an evaluation scenario.

A scenario is a set of steps that splits data into training, validation and test datasets. The test dataset is made up of two components: a fold-in set of interactions that is used to predict another held-out set of interactions. The creation of the validation dataset, from the full training dataset, should follow the same splitting strategy as the one used to create training and test datasets from the full dataset.

Parameters
  • validation (boolean, optional) – Create validation datasets when True, else split into training and test datasets.

  • seed (int, optional) – Seed for randomisation parts of the scenario. Defaults to None, so random seed will be generated.

Methods

split(data_m)

Splits data_m according to the scenario.

Attributes

full_training_data

The full training dataset, which should be used for a final training after hyper parameter optimisation.

test_data

The test dataset.

test_data_in

Fold-in part of the test dataset

test_data_out

Held-out part of the test dataset

validation_data

The validation dataset.

validation_data_in

Fold-in part of the validation dataset

validation_data_out

Held-out part of the validation dataset

validation_training_data

The training data to be used during validation.

property full_training_data: recpack.matrix.interaction_matrix.InteractionMatrix

The full training dataset, which should be used for a final training after hyper parameter optimisation.

Returns

Interaction Matrix of training interactions.

Return type

InteractionMatrix

split(data_m: recpack.matrix.interaction_matrix.InteractionMatrix) None

Splits data_m according to the scenario.

After splitting properties training_data, validation_data and test_data can be used to retrieve the splitted data.

Parameters

data_m – Interaction matrix that should be split.

property test_data: Tuple[recpack.matrix.interaction_matrix.InteractionMatrix, recpack.matrix.interaction_matrix.InteractionMatrix]

The test dataset. Consist of a fold-in and hold-out set of interactions.

Data is processed such that both matrices contain the exact same users. Users that were present in only one of the matrices and not in the other are removed.

Returns

Test data matrices as InteractionMatrix in, InteractionMatrix out.

Return type

Tuple[InteractionMatrix, InteractionMatrix]

property test_data_in

Fold-in part of the test dataset

property test_data_out

Held-out part of the test dataset

property validation_data: Optional[Tuple[recpack.matrix.interaction_matrix.InteractionMatrix, recpack.matrix.interaction_matrix.InteractionMatrix]]

The validation dataset. Consist of a fold-in and hold-out set of interactions.

Data is processed such that both matrices contain the exact same users. Users that were present in only one of the matrices and not in the other are removed.

Returns

Validation data matrices as InteractionMatrix in, InteractionMatrix out.

Return type

Tuple[InteractionMatrix, InteractionMatrix]

property validation_data_in

Fold-in part of the validation dataset

property validation_data_out

Held-out part of the validation dataset

property validation_training_data: recpack.matrix.interaction_matrix.InteractionMatrix

The training data to be used during validation.