recpack.scenarios.splitters.MostRecentSplitter
- class recpack.scenarios.splitters.MostRecentSplitter(n: int)
Splits the n most recent interactions of a user into the second return value, and earlier interactions into the first.
- Parameters
n (int) – Number of most recent actions to assign to the second return value. If
n
is negative, all but then
earliest interactions are assigned to the second return value.
Methods
split
(data)Splits the n most recent interactions of a user into
data_out
, and earlier interactions intodata_in
.Attributes
String identifier of the splitter object, contains name and parameter values.
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 the n most recent interactions of a user into
data_out
, and earlier interactions intodata_in
.- Parameters
data (InteractionMatrix) – Interaction matrix to be split. Must contain timestamps.
- Returns
A 2-tuple containing the
data_in
anddata_out
matrices.- Return type
Tuple[InteractionMatrix, InteractionMatrix]