recpack.scenarios.splitters.FractionInteractionSplitter

class recpack.scenarios.splitters.FractionInteractionSplitter(in_frac, seed: Optional[int] = None)

Split data randomly, such that in_fraction of interactions are assigned to the first return value and the remainder to the second.

Parameters
  • in_frac (float) – Fraction of events to end up in the first return value.

  • seed (int, optional) – Seed the random generator. Set this value if you require reproducible results. Defaults to None, which results in a random seed.

Methods

split(data)

Splits data randomly, such that in_fraction of interactions are assigned to data_in and the remainder to data_out.

Attributes

identifier

String identifier of the splitter object, contains name and parameter values.

name

The name of the splitter.

property identifier

String identifier of the splitter object, contains name and parameter values.

property name

The name of the splitter.

split(data: recpack.matrix.interaction_matrix.InteractionMatrix) Tuple[recpack.matrix.interaction_matrix.InteractionMatrix, recpack.matrix.interaction_matrix.InteractionMatrix]

Splits data randomly, such that in_fraction of interactions are assigned to data_in and the remainder to data_out.

Parameters

data (InteractionMatrix) – Interaction matrix to be split.

Returns

A 2-tuple containing the data_in and data_out matrices.

Return type

Tuple[InteractionMatrix, InteractionMatrix]